diff --git a/src/CourseRegistrationStarter/RegistrationSystem.java b/src/CourseRegistrationStarter/RegistrationSystem.java index 934f222..02cb5ea 100644 --- a/src/CourseRegistrationStarter/RegistrationSystem.java +++ b/src/CourseRegistrationStarter/RegistrationSystem.java @@ -1,24 +1,54 @@ package CourseRegistrationStarter; import java.util.ArrayList; -public class RegistrationSystem { +public class RegistrationSystem +{ private ArrayList courses; public RegistrationSystem() { courses = new ArrayList<>(); } - public void addCourseToSystem(Course c) { - // TODO: Add the course to the system + public void addCourseToSystem(Course c) + { + 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 + public Course findCourseByCode(String code) + { + if(courses.isEmpty()) + { + System.out.println("NOTHING HAS FOUND !"); + return null; + } + else + { + for(int i = 0; i < courses.size(); i++) + { + Course c = courses.get(i); + if(code.equals(c.getCourseCode())) + { + return c; + } + } + } + System.out.println("NOTHING HAS FOUND !"); return null; } - public void showAllCourses() { - // TODO: Print all courses in the system + public void showAllCourses() + { + if(courses.isEmpty()) + { + System.out.println("NOTHING HAS FOUND !"); + } + + for(int i = 0; i < courses.size(); i++) + { + Course c = courses.get(i); + System.out.println("Course "+ (i + 1) + " : " + c.getCourseName() + + " | code : " + c.getCourseCode() + + " | cpacity : " + c.getCapacity()); + } } -} +} \ No newline at end of file