Lab 8: Working with Cyclic Data
Goals: The goal of this lab is to learn how to design and use circularly referential data.
Submissions: This is due at the end of your lab period. Create the classes needed for the Registrar problem described below. In a file named ExamplesRegistrar.java add examples for all of your classes. Add tests for the enroll, classmates and dejavu methods. Submit this file to handins. This will be graded mainly on the completeness of your test cases. Note, partners can work on this together, but will submit their work individually. You will be continuing this problem for Assignment 7.
In addition, please fill out the brief survey on pair programming here. This can be submitted any time during the day today (2/25/25) up to 11:59pm.
8.1 The Registrar’s Office
The registrar’s office maintains a great deal of information about classes, instructors, and students. Your task in this problem is to model that data, and implement a few methods on it. We deliberately do not give you the class diagram for this problem: from the description below, you should properly design whatever classes you think are relevant. Please use generic lists (i.e. IList<T>) for this problem.
8.1.1 Data constraints
A Course consists of a name (a String), an Instructor named prof, and a list of Students named students. No Course can be constructed without an Instructor available to teach it. Hint: Do you think that you should provide a list when constructing a Course? Why or why not?
An Instructor has a name and a list of Courses named courses he/she/they teaches. Instructors are initially constructed without any Courses to teach.
A Student has a name, an 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 Instructor for any Course should have that Course appear in the Instructor’s list of Courses.
8.1.2 Methods and examples to design
Design a method void enroll(Course c) that enrolls a Student in the given Course. Design any helper methods as appropriate.
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 Instructor’s Courses.
Construct example data consisting of at least five Students, at least four Courses and at least two Instructors. Test all your methods thoroughly.