Assignment 11: Course Registration
Commonwealth maintains a great deal of information about classes, teachers, and students. You will model (some of) that data and implement a few methods. Please use generic lists (i.e. IList<T>) for this problem.
11.1 Data constraints
A Course consists of a name (a String), a Teacher, and a list of Students. No Course can be constructed without a Teacher available to teach it. Hint: Think carefully about what a Course needs to be constructed, and what good default values would be for certain fields.
A Teacher has a name and a list of Courses they teach. Teachers are initially constructed without any Courses to teach.
A Student has a name, an unique id number (an int), and a list of Courses they are taking. Students are initially constructed without taking any Courses.
It should always be the case that any Student who is enrolled in a Course should appear in the list of Students for that Course, and the Course should likewise appear in the Student’s list of Courses.
It should always be the case that the Teacher for any Course should have that Course appear in the Teacher’s list of Courses.
11.2 Methods to design
Design a method void enroll(Course c) that enrolls a Student in the given Course. Design any helper methods as appropriate.
Note: If a Student is enrolled in a Course more than once, they should only appear once in that Course’s list of Students and the Course should only appear once in their list of Courses.
Hint: You are dealing with generic lists, so what kind of abstraction will enable you to determine if something is in a list?
Design a method boolean classmates(Student c) that determines whether the given Student is in any of the same classes as this Student.
Design a method boolean dejavu(Student c) that determines whether the given Student is in more than one of this Teacher’s Courses.