+-------------------------------------------------+ | +-------------------+ | | | | | | v | v | +------+ | +------+ | | ALoS |<-------------+ | | ALoC |<------------+ | +------+ | | +------+ | | +------+ | | +------+ | | / \ | | / \ | | --- | | --- | | | | | | | | ---------------- | | ---------------- | | | | | | | | | | +-------+ +---------------+ | | +-------+ +--------------+ | | | MTLoS | | ConsLoS | | | | MTLoC | | ConsLoC | | | +-------+ +---------------+ | | +-------+ +--------------+ | | +-------+ +-| Student first | | | +-------+ +-| Course first | | | | | ALoS rest |-+ | | | ALoC rest |-+ | | +---------------+ | | +--------------+ | | | | | v | v | +--------------+ | +-------------+ | | Student | | | Course | | +--------------+ | +-------------+ | | String name | | | String name | | | int id | | | int credits | +----| ALoC courses | +-----| ALoS roster | +--------------+ +-------------+
Define examples of at least three students and eight courses, with every student enrolled in at least two courses.
Design the method addCourse in the class Student that will enroll the student in the given course. Throw an exception if the student is already enrolled in the course, or if the total number of credits would be over 20, after the enrollment is completed.
Design the method dropCourse that will drop the student from the given course. Throw an exception if the student is not enrolled in the given course, or if it would result in student being registered for fewer than two courses, after the drop is processed.
A student meets an attractive fellow student and wonders whether they may meet during one of the classes our student is enrolled in. Design the method canMeet that will tell our student whether there is a course our student is taking that the desired person is also enrolled in.
The registrar keeps a list of all students and a list of all courses. These are set up at the beginning of each quarter. Design the class Registrar and include your original examples in the registrar’s database.
Design the method register that consumes the name of a student, the student’s id, and the course name and enrolls the student in the course. The same restrictions as before apply. Additionally, the method should throw an exception if any of the information given is not correct (no student with the given name and id, no course with the given name).
Design the method withdraw that consumes the name of a student, the student’s id, and the course name and drops the student from the course. The same restrictions as before apply. Additionally, the method should throw an exception if any of the information given is not correct (no student with the given name and id, no course with the given name).
Note: Most of these methods require several helper methods. At least half of the grade for this homework will assess the design of these methods - whether you truly follow the rule one task — one method.
Note: All of these methods, except the canMeet method are defined only to effect a change in the registrar system. Design your tests carefully. At least one half of the grade for this homework will assess the design and implementation of the tests for these methods.
Note: Did you notice that the above two criteria cover two halves of the grade for the homework? Well, there is some wiggle room there, but we really want you to understand how important these two issues are.