This is what I need to do.
When user type “grade,111111111,11111,A” assign a grade of A to the student, with RUID of 111111111, against course, with index of 11111.
4.1 View class will handle input and call CourseRegistrationController singleton object to get things done.
4.2 CourseRegistrationController.grade method will
4.2.1 First to call CourseOfferingContoller.getCourse method to get the Course object with index number of 11111.
4.2.2 It then call Course.grade method to assign grade to student with RUID of 111111111.
4.3 Course.grade method will get the Enrollment object from its Hashtable, with RUID of 111111111. And call Enrollment.setGrade to change the grade.
I have done all this, but kind of stuck of what to do next
Here is the last step 4.3
Code :
// assign a grade to a student through // roster list public Enrollment grade(String RUID, String grade){ Enrollment g = (Enrollment) enrollments.get(RUID); g.setGrade(grade); return null;
enrollment class
Code :
public void setGrade(String grade) { this.grade = grade; } public String getGrade() { // when assign a grade to a student // you also need to recalculate GPA return grade; }
Im stuck on the "to change the grade." part. I am not sure where I store the grade for each course. I have 4 hash tables, one stores all the courses( index is course id and object is course name) one stores all students( index is student id and object is student name) one stores all the students in a class( index is course id and object is student name) and the other stores all the classes the one student is in. ( index is student id and object is course name)
But does not seem right.
In the course class, it has the method grade which says it // assign a grade to a student through roster list, but I don't see how since the index for that hashtable is the course id. How would I be able to find a particular student in the hashtable? Also how would I go about adding this grade? I was thinking something like this
Code :
public Enrollment grade(String RUID, String grade){ Enrollment g = (Enrollment) enrollments.get(RUID); g.setGrade(grade); enrollments.put(g.getCourse(), g ); return null;
Then the gpa is stored in the hashtable with index being student id, but not sure how I would be able to view the grades in the other hashtable. I would assume using the enrollments.get but i am lost. To me it seems like it would be easier to just make another hashtable for grades and somehow have them linked or something. idk I am just confused.
thanks