package studentDB; /** * * Represents a course. A course has a title, and a list * of students taking it. * */ public class CourseImpl implements Course { // The title of the course private String title; // The list of students taking the course private StudentList students; /** * @param title The title of the course */ public CourseImpl (String title) { this.title = title; students = new StudentListImpl(); } /** * Sets the title of the course. * @param title The title of the course */ public void setTitle (String title) { this.title = title; } /** * Returns the title of the course. * @return The title of the course */ public String getTitle () { return title; } /** * Sets the list of enrolled students to the given list. * @param students The students enrolled in this course */ public void setEnrolledStudents (StudentList students) { this.students = students; } /** * Returns the list of students enrolled in this course. * @return The students enrolled in this course */ public StudentList getEnrolledStudents () { return students; } /** * Determines whether this course is equal to the given * course. Two courses are equal if their titles are * the same. * @param c The course we are testing for equality * @return Whether this course is equal to given course */ public boolean equals (Course c) { return title.equals (c.getTitle()); } /** * Returns a string representation of the course, * listing the course's title and enrolled students. * @return String representation of course */ public String toString() { return title; } }