Complete Work Shop 2

This commit is contained in:
2026-06-16 16:24:35 +03:30
parent 8ddd529c85
commit e9370069cf
3 changed files with 41 additions and 18 deletions
@@ -9,16 +9,21 @@ public class RegistrationSystem {
}
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 (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.getCourseCode() + " - " + c.getCourseName() + " (Capacity: " + c.getCapacity() + ")");
}
}
}