workshop done
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user