Files
WS-02-intro-to-oop-Saeed/src/CourseRegistrationStarter/RegistrationSystem.java
T

34 lines
907 B
Java

package CourseRegistrationStarter;
import java.util.ArrayList;
public class RegistrationSystem {
private ArrayList<Course> courses;
public RegistrationSystem() {
courses = new ArrayList<>();
}
public void addCourseToSystem(Course c) {
this.courses.add(c);
// TODO: Add the course to the system
}
public Course findCourseByCode(String code) {
for (Course c: this.courses) {
if (c.getCourseCode().equals(code)) {
return c;
}
}
// TODO: Search for a course by course code
// Return the matching course if found, otherwise return null
return null;
}
public void showAllCourses() {
for(Course c: this.courses) {
System.out.println(c.getCourseName() + ", code: " + c.getCourseCode());
}
// TODO: Print all courses in the system
}
}