-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f8965c5
Showing
14 changed files
with
1,002 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package Comparators; | ||
|
||
import StudentClass.*; | ||
import java.util.Comparator; | ||
|
||
/* Comparator added as the Student class does not implement comparable | ||
so to compare a class which does not implement comparable you should | ||
add a comparator*/ | ||
|
||
public class FinalMarks implements Comparator<Student> { | ||
|
||
/* An overridden method in the super class Object. | ||
The method has two arguments where two objects | ||
of Student must be given then the method will | ||
compare the final marks of the compared students. | ||
*/ | ||
@Override | ||
public int compare (Student o1, Student o2){ | ||
return o1.getFinalMarks() - o2.getFinalMarks(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package Comparators; | ||
|
||
import java.util.Comparator; | ||
import StudentClass.*; | ||
|
||
/* Comparator added as the Student class does not implement comparable | ||
so to compare a class which does not implement comparable you should | ||
add a comparator*/ | ||
|
||
public class LastName implements Comparator <Student> { | ||
|
||
/* An overridden method in the super class Object. | ||
The method has two arguments where two objects | ||
of Student must be given then the method will | ||
compare the last name of the compared students. | ||
*/ | ||
@Override | ||
public int compare (Student o1, Student o2){ | ||
return o1.getlName().compareTo(o2.getlName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package Enum; | ||
|
||
/* This is an enum which is like our own string | ||
which will only contain the values which are mentioned | ||
below | ||
*/ | ||
public enum Grade { | ||
First_Class, Second_Upper_Class, Second_Lower_Class, General_Pass, Fail_Resit, Fail_Retake | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package GUI; | ||
|
||
import GUI.StarCreation.Horizontal_Star; | ||
import StudentClass.Student; | ||
import StudentTester.Test; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class Horizontal_View extends JFrame { | ||
public Horizontal_View() { | ||
super("Overall Marks in Horizontal Histogram"); | ||
setSize(450, 350); | ||
|
||
JPanel mainPanel = new JPanel(); | ||
mainPanel.setLayout(new BorderLayout()); | ||
add(mainPanel); | ||
|
||
JPanel subPanel1 = new JPanel(); | ||
JLabel header = new JLabel("Horizontal Histogram"); | ||
subPanel1.add(header); | ||
mainPanel.add(subPanel1, BorderLayout.PAGE_START); | ||
|
||
JPanel subPanel2 = new JPanel(); | ||
subPanel2.setLayout(new GridLayout(4, 1)); | ||
|
||
JLabel lbl1 = new JLabel(" 0 - 29"); | ||
JLabel lbl2 = new JLabel("30 - 39"); | ||
JLabel lbl3 = new JLabel("40 - 69"); | ||
JLabel lbl4 = new JLabel("70 - 100"); | ||
|
||
subPanel2.add(lbl1); | ||
subPanel2.add(lbl2); | ||
subPanel2.add(lbl3); | ||
subPanel2.add(lbl4); | ||
|
||
mainPanel.add(subPanel2, BorderLayout.LINE_START); | ||
|
||
JPanel subPanel3 = new JPanel(); | ||
subPanel3.setLayout(new GridLayout(4, 1)); | ||
|
||
int num1 = 0; | ||
int num2 = 0; | ||
int num3 = 0; | ||
int num4 = 0; | ||
for (Student student : Test.students) { | ||
if (student.getFinalMarks() < 30) num1++; | ||
else if (student.getFinalMarks() < 40) num2++; | ||
else if (student.getFinalMarks() < 70) num3++; | ||
else num4++; | ||
} | ||
subPanel3.add(new Horizontal_Star(num1));//Adding stars | ||
subPanel3.add(new Horizontal_Star(num2));//Adding stars | ||
subPanel3.add(new Horizontal_Star(num3));//Adding stars | ||
subPanel3.add(new Horizontal_Star(num4));//Adding stars | ||
mainPanel.add(subPanel3, BorderLayout.CENTER); | ||
|
||
JLabel noOfStds = new JLabel("Total number of students : " + Test.students.size()); | ||
mainPanel.add(noOfStds, BorderLayout.PAGE_END); | ||
|
||
setVisible(true); | ||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package GUI.StarCreation; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class Horizontal_Star extends JPanel { | ||
|
||
private int nStars = 0; | ||
|
||
// Overridden paint method to paint our own string | ||
@Override | ||
public void paint(Graphics g) {//Using graphics to display the stars | ||
Graphics2D g2d = (Graphics2D) g; | ||
for (int i = 0; i < nStars; i++) { | ||
g2d.setFont(new Font("TimesRoman", Font.BOLD, 20)); | ||
g2d.setColor(Color.BLACK); | ||
g2d.drawString("*", 20 + (i * 10), 45); | ||
} | ||
} | ||
|
||
// Non Default constructor | ||
public Horizontal_Star(int list) { | ||
this.nStars = list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package GUI.StarCreation; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class Vertical_Star extends JPanel { | ||
|
||
private int nStars = 0; | ||
|
||
// Overridden paint method to paint our own string | ||
@Override | ||
public void paint(Graphics g) {//Using graphics to display the stars | ||
Graphics2D g2d = (Graphics2D) g; | ||
for (int i = 0; i < nStars; i++) { | ||
g2d.setFont(new Font("TimesRoman", Font.BOLD, 20)); | ||
g2d.setColor(Color.BLACK); | ||
g2d.drawString("*", 15, 20 + (i * 10)); | ||
} | ||
} | ||
|
||
// Non Default constructor | ||
public Vertical_Star(int list) { | ||
this.nStars = list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package GUI; | ||
|
||
import GUI.StarCreation.Vertical_Star; | ||
import StudentClass.Student; | ||
import StudentTester.Test; | ||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class Vertical_View extends JFrame { | ||
public Vertical_View() { | ||
super("Overall Marks in Vertical Histogram"); | ||
setSize(450, 350); | ||
|
||
JPanel mainPanel = new JPanel(); | ||
mainPanel.setLayout(new BorderLayout()); | ||
add(mainPanel); | ||
|
||
|
||
JPanel subPanel1 = new JPanel(); | ||
subPanel1.setLayout(new GridLayout(1, 4)); | ||
|
||
JLabel lbl1 = new JLabel(" 0 - 29"); | ||
JLabel lbl2 = new JLabel("30 - 39"); | ||
JLabel lbl3 = new JLabel("40 - 69"); | ||
JLabel lbl4 = new JLabel("70 - 100"); | ||
|
||
subPanel1.add(lbl1); | ||
subPanel1.add(lbl2); | ||
subPanel1.add(lbl3); | ||
subPanel1.add(lbl4); | ||
|
||
mainPanel.add(subPanel1, BorderLayout.PAGE_START); | ||
|
||
JPanel subPanel2 = new JPanel(); | ||
subPanel2.setLayout(new GridLayout(1, 4)); | ||
|
||
int num1 = 0; | ||
int num2 = 0; | ||
int num3 = 0; | ||
int num4 = 0; | ||
for (Student student : Test.students) { | ||
if (student.getFinalMarks() < 30) num1++; | ||
else if (student.getFinalMarks() < 40) num2++; | ||
else if (student.getFinalMarks() < 70) num3++; | ||
else num4++; | ||
} | ||
subPanel2.add(new Vertical_Star(num1));//Adding stars | ||
subPanel2.add(new Vertical_Star(num2));//Adding stars | ||
subPanel2.add(new Vertical_Star(num3));//Adding stars | ||
subPanel2.add(new Vertical_Star(num4));//Adding stars | ||
mainPanel.add(subPanel2, BorderLayout.CENTER); | ||
|
||
JLabel noOfStds = new JLabel("Total number of students : " + Test.students.size()); | ||
mainPanel.add(noOfStds, BorderLayout.PAGE_END); | ||
|
||
setVisible(true); | ||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package StudentClass; | ||
|
||
import Enum.*; | ||
import java.io.Serializable; | ||
|
||
public class Student implements Serializable { | ||
|
||
// Encapsulating data fields so they cannot be accessed directly | ||
private String fName; | ||
private String lName; | ||
private int regNo; | ||
private int ict_01_marks; | ||
private int ict_02_marks; | ||
private int cw_01_marks; | ||
private int cw_02_marks; | ||
private int finalMarks; | ||
private Grade grade; | ||
|
||
// Default Constructor. I have added this cause this improves coding standards | ||
public Student() { | ||
|
||
} | ||
|
||
// Non default constructor | ||
public Student(String fName, String lName, int regNo, int ict_01_marks, | ||
int ict_02_marks, int cw_01_marks, int cw_02_marks) { | ||
this.fName = fName; | ||
this.lName = lName; | ||
this.regNo = regNo; | ||
this.ict_01_marks = ict_01_marks; | ||
this.ict_02_marks = ict_02_marks; | ||
this.cw_01_marks = cw_01_marks; | ||
this.cw_02_marks = cw_02_marks; | ||
this.finalMarks = this.getFinalMarks(); | ||
this.grade = this.getGrade(); | ||
} | ||
|
||
// Getter and Setter methods | ||
public String getfName() { | ||
return fName; | ||
} | ||
|
||
public void setfName(String fName) { | ||
this.fName = fName; | ||
} | ||
|
||
public String getlName() { | ||
return lName; | ||
} | ||
|
||
public void setlName(String lName) { | ||
this.lName = lName; | ||
} | ||
|
||
public int getRegNo() { | ||
return regNo; | ||
} | ||
|
||
public void setRegNo(int regNo) { | ||
this.regNo = regNo; | ||
} | ||
|
||
public int getIct_01_marks() { | ||
return ict_01_marks; | ||
} | ||
|
||
public int getIct_02_marks() { | ||
return ict_02_marks; | ||
} | ||
|
||
public int getCw_01_marks() { | ||
return cw_01_marks; | ||
} | ||
|
||
public int getCw_02_marks() { | ||
return cw_02_marks; | ||
} | ||
|
||
public int getFinalMarks() { | ||
this.finalMarks = (int) Math.round((this.ict_01_marks * 0.2) + | ||
(this.ict_02_marks * 0.2) + (this.cw_01_marks * 0.3) + | ||
(this.cw_02_marks * 0.3)); | ||
return finalMarks; | ||
} | ||
|
||
public Grade getGrade() { | ||
if ((((this.ict_01_marks + this.ict_02_marks) / 2) >= 30) && | ||
this.cw_01_marks >= 30 && this.cw_02_marks >= 30 | ||
&& this.finalMarks >= 40) { | ||
if (this.finalMarks >= 70) { | ||
this.grade = Grade.First_Class; | ||
} else if (this.finalMarks >= 60) { | ||
this.grade = Grade.Second_Upper_Class; | ||
} else if (this.finalMarks >= 50) { | ||
this.grade = Grade.Second_Lower_Class; | ||
} else { | ||
this.grade = Grade.General_Pass; | ||
} | ||
} else if (this.finalMarks >= 30) { | ||
this.grade = Grade.Fail_Resit; | ||
} else { | ||
this.grade = Grade.Fail_Retake; | ||
} | ||
return grade; | ||
} | ||
} |
Oops, something went wrong.