CourseRecord, and updating the other classes as described below.
Instances of the CourseRecord class are to represent courses taken by a student. They should have fields representing the course number, the year that the course was offered, and the grade that the student received. These fields may be ints in each case. There should be a constructor taking three integers in this order. You may assume that the course number and year are correct, but the grade field is to be between 0 and 100. So your constructor should increase any negative grades to 0, and reduce to 100 any grades that exceed 100.
As was the case for the StudentRecord class in Assignment 3, instances of the CourseRecord class will need to be printed and sorted. In addition, you will need to look up a student's grade for a course, given the course number and the year it was taken. You needn't provide any methods for the CourseRecord except for the methods needed to facilitate these operations.
The StudentRecord class should be updated to maintain a collection of CourseRecords for the corresponding student. It should have new methods add, traverse, findGrade, and getCourseList. The add method should take a CourseRecord object as parameter, and add it to the collection of course records unless it is null, or it has the same course number and year as an existing record in the collection. In this last case, it should treat the add request as an update and return the existing CourseRecord for that year and course number (so its return type is CourseRecord). Otherwise it should return null.
The void traverse() method should print the student's ID number and name, followed by the list of courses (in sorted order) taken by the student. For this sorted order, the year should be the most significant field (later years first) followed by the course number (lowest first). Note that it's somewhat more efficient to actually store the collection of courses in this order, since course records will tend to be added in increasing order of year. If you do store the collection in this order, then you may pass the println message to the collection as part of your traversal.
The findGrade method should take a year and a course number and returns an intthe grade received for that course in that year. If the student didn't take the given course in the given year, the method should return a negative value.
The getCourseList() method should return a List representing the set of courses taken by a student. Mutations to the return value should not modify the student record.
The StudentFile class should provide new methods findStudentRecord and getCourseList. Both methods are to take an int representing a student ID number as parameter. The first method should return the StudentRecord with that id number, or null if none exists. The second method should return a List representing the set of courses taken by the student with the given ID number. Mutations to the return value should not modify that student's record. You needn't find a student record by name or provide a traverseByName method. You will still need a traverseByNumber method.
The StudentFile.add method should be modified to treat insertion of students with an existing id number as an update, returning the existing student record in this case, and null otherwise. Note that the TreeMap class does this automatically, as well as providing efficient insertion and lookup methods. Whether or not you use this class, you should assume that search is common compared to insertion. There may be a penalty for serious inefficiencies in your classes and methods.
Chapter 11 discusses a technique for efficient search in sorted arrays.
Since there is no class on March 24 (or on the 26th or the 31st), late submissions may not be accepted, or may be accepted but with a due date earlier than usual. Details will be provided in class.