34 lines
908 B
Java
34 lines
908 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) {
|
|
// TODO: Add the course to the system
|
|
courses.add(c);
|
|
}
|
|
|
|
public Course findCourseByCode(String code) {
|
|
// TODO: Search for a course by course code
|
|
// Return the matching course if found, otherwise return null
|
|
|
|
for(int i=0; i<courses.size(); i++){
|
|
if (((courses.get(i)).getCourseCode()).equals(code))
|
|
return courses.get(i);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void showAllCourses() {
|
|
// TODO: Print all courses in the system
|
|
for (int i = 0; i < courses.size(); i++) {
|
|
System.out.println(courses.get(i).getCourseName());
|
|
}
|
|
}
|
|
}
|