Files
tamrin2/src/CourseRegistrationStarter/RegistrationSystem.java
T
2026-04-21 00:26:14 +03:30

37 lines
949 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
//return null;
for (Course c : courses) {
if (c.getCourseCode().equals(code)) {
return c;
}
}
return null;
}
public void showAllCourses() {
// TODO: Print all courses in the system
for (Course c : courses) {
System.out.println(c.getCourseName() + " (" + c.getCourseCode() + ") Capacity: " + c.getCapacity());
}
}
}