Make sure to develop your program incrementally. Remember to spend some time designing your application and decomposing methods into small easily tested chunks. Ensure that your classes are working correctly. Thus, each class should have a short main method that performs a unit test on as much of the class as is possible. The coding in this assignment is not difficult, but there are more classes to deal with than in the past, and your system design will matter a great deal.
Also continue javadoc'ing and commenting your code to make it understandable and useable. A good quote that you should keep in mind when commenting your code is, "Always code as if the person who will have to maintain your code is a violent psychopath who knows where you live."
Students are either undergraduates or graduates. Every student has a first name, a last name, and a student ID (integer). Undergrad students also have a class year: freshman (FR), sophomore(SO), junior(JR) and senior(SR). Grad students are either masters (MS) or PhD (PHD), and they also are with a teaching assistant (TA), research assistant (RA), or unfunded (NONE). To handle these categories, you must create an abstract base class named Student. Student should have two subclasses: UndergradStudent and GradStudent.
Your program should also include a class named Course that corresponds to a particular class that a set of students are taking. Courses have names, major codes and numbers (i.e. Introduction to Programming, CS, 1321). The name is the course name and may include spaces. The major code is from 2-4 characters in length, like CS, ISYE. The course number is an integer.
Think carefully about other classes that your program should use as well.
You should assume that there will be at least one existing file that has the specifications for a particular course. The first line of the input file will contain the course major code, number and name. As mentioned above, the courses we'll be examining will have both undergraduate and graduate students in them. The grading criteria and number of assignments may vary for the two groups.
A student's grade is determined by a set of categories and weights. The next eight lines of the input file will contain the categories, the weights and the maximum points available for that assignment. You may assume that the order will always be a category line followed by a weight line, followed by a max points line although the undergraduate and graduate block may appear in any order. The first entry of a block is a single U (undergrad) or G (grad) will denote which grade criteria you are dealing with.
For example consider a sample undergraduate grading criteria:
5 HWs
(20%) [4%each]
2 Tests (40%) [20% each]
Participation ( 5%)
Final Exam
(35%)
A graduate student's grade is determined by the criteria:
5 HWs
(15%) [3% each]
2 Tests (30%) [15% each]
Participation ( 5%)
Final Project
(20%)
Final Exam (30%)
The remainder of the lines in the file will be the student data. Undergrad and grad students may be intermixed in the file. The format of an undergraduate student data line is:
lastname firstname studentID status student's_scores
The format of a graduate student data line is:
lastname firstname studentID status funding students's_scores
A sample input file format for 3 students appears below (data in the file is space delimited):
CS 1323 Intro To Really Hard Programming U hw1 hw2 hw3 hw4 hw5 test1 test2 part final 4 4 4 4 4 20 20 5 35 50 50 50 50 50 100 100 5 100 G hw1 hw2 hw3 hw4 hw5 test1 test2 part proj final 3 3 3 3 3 15 15 5 20 30 50 50 50 50 50 100 100 5 100 100 Smith Mary 435763 SO 50 45 45 50 40 86 80 5 79 Jones William 735213 SR 50 40 35 35 40 68 77 5 73 Wilson Betty 984265 PHD TA 50 50 50 45 47 89 82 5 78 91
This is a sample file only. We may test your application with the G block first. We may have different assignment categories, numbers of assignments, weights or maximum points. We may have certain errors in the file (see the exceptions section). What we promise is that the next three lines after the U or G in the criteria will be in the correct order.
The student individual assignment scores are always integers. A student cannot score a negative on an assignment. The course average should be held in a double and displayed to 1 decimal place. A student's course average would be determined by first computing their percentage out of 100 for an assignment using their grade/max points. This value is then multiplied by the weight to get their total points for that assignment. These assignment points are then summed up to get the complete course average. As as example, consider Mary Smith below. We know from her SO code she is an undergrad. Thus her grades are 50/50 45/50 45/50 50/50 40/50 86/100 80/100 5/5 and 79/100. To compute her average we have:
((50/50) * 4) + ((45/50) *4) + ((45/50)*4) + ((50/50) *4) + ((40/50) *4) + ((86/100) *20) + ((80/100)*20)+((5/5)*5) + ((79/100)*35)
or
4 + 3.6 + 3.6 + 4 + 3.2 + 17.2 + 16 + 5 + 27.65 = 84.3
The constructor for the Course class should take a string argument that is an input file name that specifies one of the data files as shown above. The Course class should also provide the following methods:
String getMajorCode() - Returns the course major code (e.g., CS)
int getNumber() - Returns the course number
String getName() - Returns the course name
void displayRoster() - Displays the
class roster in alphabetical order in a pop-up window (a GUI
panel). See the UI description section below for the format.
void exportScores() - Write out to the
file "majorandnumber.data" a list of the students in the class,
sorted by their final average from highest to lowest. (For example,
the filename might be "cs1322.data" or "ae4562.data", etc.) Each
line of the output file should be:
lastname firstname studentID average
We will leave the design of the Student classes more open and will observe the methods that you create. The Student class should, however, implement the Comparable interface so that it can be sorted on required criteria. All your relevant classes should also override important methods in Object like toString as well.
Your main interface should consist of three buttons and a Label in a JFrame. The three buttons should be:
Load: This displays a dialog requesting the user to enter a filename. You may use a simple JOptionPane.showInputDialog or if you know how, you may use a JFileChooser (sample listing 8.13 in the book); Pressing this button should create a new Course object. All other button presses should be ignored until there is a course selected. If the user loads a second course, the first course should be destroyed and the second course becomes the active course.
Save: This button tells the system to write out the class roster to the appropriate file (e.g., cs1322.data, me1200.data), sorted by student averages. This button should be ignored if no course has been loaded. You should call the exportScores method in Course to write out this file.
Display: This displays an alphabetic class roster in a separate JFrame. Pressing this button with no course loaded should have no effect. Otherwise, pressing this button should call the displayRoster method of the Course class. See below for layout.
A label also should be displayed in the main window showing the area, number, and name of the current course. If no course has been loaded yet, the label should read "No Active Course".
The actual layout of these items is left to you. Your GUI should present a nice overall appearance, however, and not look jumbled up.
The user interface for the class roster display should be a JFrame with the title made up of the major code, number and the phrase "Class Roster" thus for our example it should be "CS1322 Class Roster". The JFrame should contain a panel that has the following columns:
Last Name First Name Average Class
Johnson Ben 89.7 U
Jones Mary 84.5 U
Smith Beth 100 G
Overall Class Average: 91.4
Note: The class column should indicate whether the students are a graduate (G) or undergraduate (U). Columns should be lined up, but do not have to be centered. Decimal points do not have to be aligned. Averages should only be displayed to 1 decimal place xx.x HINT: review DecimalFormat class (see listing 7.28 for example).
You do not need to worry about scrolling. For those advanced students that want to have scrolling output, take a look at JScrollPane in the API. Everyone else can do a JPanel derived class. We will test it with a number of names that will fit on one screen. Remember that to draw on a panel, you will need to create your own panel subclass and override the paintComponent method as we have done in breakouts.
You should create your own Exception class named BadFileFormatException that is derived from class Exception (therefore it is a checked exception).
If there is an anomaly in the file, you should throw a BadFileFormatException. BadFileFormatException should take a character string that is a description of the error.
The following errors at a minimum should be detected (thus are "legal" for us to test your code with):
Mismatched Criteria Length (there was a problem in the number of categories, weights and max points counts. Obviously these all need to be the same i.e. if there are 5 categories there should be 5 weights and 5 max point entries).
Bad Input Line (On a student line entry, there is missing information i.e. not enough grades).
Can't Determine Status (On a student line entry, the status was not: FR, SO, JR, SR, MS, or PHD).
Bad Grade Entry (One of the student grades could not be converted to an integer.)
The following actions should be taken:
Mismatched Criteria Length. Notify the user of the error and return to main window. User may try to load another file.
Bad Input Line. Write the line to System.err, skip that student and continue processing the file
Can't Determine Status: Write the line to System.err, skip that student and continue processing the file
Bad Grade Entry: Write the line to System.err, skip that student and continue processing the file. For advanced students that want to try optional features, try to recover by parsing the grade and removing the non-numeric entry. For example 45s should be changed to 45. t56 should be 56. 4s5 should be 45. If there is not a numeric entry at all (i.e. st), then skip that student and continue processing the file. Note that this level of correction is NOT required to get full credit on the assignment. This is only for advanced students who are not challenged by the rest of the assignment.
Course.java
MainGUI.java
ReportGUI.java
ReportPanel.java
Student.java
BadFileFormatException.java
UndergradStudent.java
GradStudent.java