37 lines
931 B
Java
37 lines
931 B
Java
import java.util.ArrayList;
|
|
|
|
public class RegistrationSystem {
|
|
private ArrayList<Course> courses;
|
|
|
|
public RegistrationSystem() {
|
|
courses = new ArrayList<>();
|
|
}
|
|
|
|
public void addCourseToSystem(Course c) {
|
|
// Add the course to the system
|
|
courses.add(c);
|
|
}
|
|
|
|
public Course findCourseByCode(String code) {
|
|
// Search for a course by course code
|
|
for (Course c : courses) {
|
|
if (c.getCourseCode().equals(code)) {
|
|
return c;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void showAllCourses() {
|
|
// Print all courses in the system
|
|
for (Course c : courses) {
|
|
System.out.println(
|
|
c.getCourseName() + " - " +
|
|
c.getCourseCode() +
|
|
" | Remaining capacity: " +
|
|
c.getCapacity()
|
|
);
|
|
}
|
|
}
|
|
}
|