From a4245b41a67b88a6edb2ad3815d09e0cd20130d9 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Mon, 20 Apr 2026 19:28:39 +0330 Subject: [PATCH] complete RegistrationSystem class --- .../RegistrationSystem.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/CourseRegistrationStarter/RegistrationSystem.java b/src/CourseRegistrationStarter/RegistrationSystem.java index 934f222..7013732 100644 --- a/src/CourseRegistrationStarter/RegistrationSystem.java +++ b/src/CourseRegistrationStarter/RegistrationSystem.java @@ -9,16 +9,32 @@ public class RegistrationSystem { } public void addCourseToSystem(Course c) { - // TODO: Add the course to the system + + for (int i=0 ; i < courses.size() ; i++) { + + if(courses.get(i).getCourseCode().equals(c.getCourseCode())) { + return; + } + } + + 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(int i=0 ; i < courses.size() ; i++) { + if(courses.get(i).getCourseCode().equals(code)) { + return courses.get(i); + } + } return null; } public void showAllCourses() { - // TODO: Print all courses in the system + for(int i=0 ; i < courses.size() ; i++) { + System.out.print("Course " + i+1 + ": "); + System.out.println(courses.get(i).getCourseName() + " " + courses.get(i).getCourseCode()); + } } }