diff --git a/CourseRegistrationSystem/.idea/vcs.xml b/CourseRegistrationSystem/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/CourseRegistrationSystem/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CourseRegistrationSystem/.idea/workspace.xml b/CourseRegistrationSystem/.idea/workspace.xml new file mode 100644 index 0000000..618fbe7 --- /dev/null +++ b/CourseRegistrationSystem/.idea/workspace.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + { + "associatedIndex": 2 +} + + + + + + + + + + 1776353250476 + + + + \ No newline at end of file diff --git a/README.md b/README.md index f86bc28..0da225d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,169 @@ # Workshop 02 - IntroToOOP +# Course Registration System — Workshop Assignment + +--- + +## Overview +In this assignment, you will complete a partially implemented course registration system using Object-Oriented Programming (OOP) concepts in Java. + +You are provided with starter code. Your task is to complete the missing parts marked with `TODO`. + +--- + +## What is Already Implemented + +The following parts are already implemented for you: + +### Course Class +- Fields: `courseName`, `courseCode`, `capacity` +- Constructor +- Getter methods +- Methods for managing capacity: + - `reduceCapacity()` + - `increaseCapacity()` + +### Student Class +- Fields and constructor +- Getter methods + +### RegistrationSystem Class +- Fields and constructor + +### Main Class +- Basic structure and instructions + +--- + +## Your Task (TODO Sections) + +You must complete all methods marked with `TODO`. + +--- + +## Requirements + +### 1. Student Class + +#### Method: `addCourse(Course c)` +- Register the student in the course +- Only allow registration if the course has available capacity +- Reduce course capacity if registration is successful +- Return `true` if successful, otherwise `false` + +--- + +#### Method: `dropCourse(Course c)` +- Remove the course from the student's registered list +- Increase course capacity after dropping +- Return `true` if the course was successfully removed, otherwise `false` + +--- + +#### Method: `showRegisteredCourses()` +- Print all courses the student is registered in +- Display course name and course code + +--- + +### 2. RegistrationSystem Class + +#### Method: `addCourseToSystem(Course c)` +- Add the course to the system list + +--- + +#### Method: `findCourseByCode(String code)` +- Search for a course using its course code +- Return the matching course if found +- Return `null` if no course is found + +--- + +#### Method: `showAllCourses()` +- Print all courses in the system +- Include: + - course name + - course code + - remaining capacity + +--- + +### 3. Main Class + +You must complete the scenario in `main`: + +- Create at least 3 courses +- Create one student +- Create a registration system +- Add courses to the system +- Register the student in some courses +- Drop one course +- Print final results + +--- + +## Example Scenario + +Create the following: + +Courses: +- Advanced Programming (AP1404, capacity 2) +- Data Structures (DS2201, capacity 1) +- Database Systems (DB3301, capacity 3) + +Student: +- Name: Ali +- ID: 402222001 + +Expected actions: +- Register the student in 2 courses +- Drop 1 course +- Print: + - Student's registered courses + - Remaining capacity of all courses + +--- + +## Constraints + +- Do NOT modify the `Course` class +- Do NOT remove existing method signatures +- You must use `ArrayList` +- Do NOT use public fields + +--- + +## Bonus (Optional) + +- Prevent duplicate course registration +- Prevent registration when capacity is full +- Limit the number of courses per student +- Add search by course name + +--- + +## Workflow + +1. Fork the repository to your own Git account +2. Clone your forked repository +3. Create a new branch named `develop`: + + git checkout -b develop + +4. Complete all TODO sections in the project +5. Commit your changes with meaningful commit messages +6. Push your branch to your repository: + + git push origin develop + +7. Create a Pull Request from `develop` to `main` + +--- + +## Submission + +- Submit the link to your Pull Request +- Your PR must be from `develop` → `main` +- Deadline: End of the day +- Your code must compile and run successfully \ No newline at end of file diff --git a/src/CourseRegistrationStarter/Course.java b/src/CourseRegistrationStarter/Course.java new file mode 100644 index 0000000..7f13a14 --- /dev/null +++ b/src/CourseRegistrationStarter/Course.java @@ -0,0 +1,37 @@ +package CourseRegistrationStarter; + +public class Course { + private String courseName; + private String courseCode; + private int capacity; + + public Course(String courseName, String courseCode, int capacity) { + this.courseName = courseName; + this.courseCode = courseCode; + this.capacity = capacity; + } + + public String getCourseName() { + return courseName; + } + + public String getCourseCode() { + return courseCode; + } + + public int getCapacity() { + return capacity; + } + + public boolean reduceCapacity() { + if (capacity > 0) { + capacity--; + return true; + } + return false; + } + + public void increaseCapacity() { + capacity++; + } +} diff --git a/src/CourseRegistrationStarter/Main.java b/src/CourseRegistrationStarter/Main.java new file mode 100644 index 0000000..8f06373 --- /dev/null +++ b/src/CourseRegistrationStarter/Main.java @@ -0,0 +1,14 @@ +package CourseRegistrationStarter; + +public class Main { + public static void main(String[] args) { + // TODO: + // 1. Create at least 3 courses + // 2. Create 1 student + // 3. Create a registration system + // 4. Add courses to the system + // 5. Register the student in some courses + // 6. Drop one course + // 7. Print the final registered course list + } +} diff --git a/src/CourseRegistrationStarter/RegistrationSystem.java b/src/CourseRegistrationStarter/RegistrationSystem.java new file mode 100644 index 0000000..934f222 --- /dev/null +++ b/src/CourseRegistrationStarter/RegistrationSystem.java @@ -0,0 +1,24 @@ +package CourseRegistrationStarter; +import java.util.ArrayList; + +public class RegistrationSystem { + private ArrayList courses; + + public RegistrationSystem() { + courses = new ArrayList<>(); + } + + public void addCourseToSystem(Course c) { + // TODO: Add the course to the system + } + + public Course findCourseByCode(String code) { + // TODO: Search for a course by course code + // Return the matching course if found, otherwise return null + return null; + } + + public void showAllCourses() { + // TODO: Print all courses in the system + } +} diff --git a/src/CourseRegistrationStarter/Student.java b/src/CourseRegistrationStarter/Student.java new file mode 100644 index 0000000..02c11d8 --- /dev/null +++ b/src/CourseRegistrationStarter/Student.java @@ -0,0 +1,39 @@ +package CourseRegistrationStarter; +import java.util.ArrayList; + +public class Student { + private String name; + private String studentId; + private ArrayList registeredCourses; + + public Student(String name, String studentId) { + this.name = name; + this.studentId = studentId; + this.registeredCourses = new ArrayList<>(); + } + + public String getName() { + return name; + } + + public String getStudentId() { + return studentId; + } + + public boolean addCourse(Course c) { + // TODO: Register the student in the course if capacity allows + // Return true if registration was successful, otherwise false + return false; + } + + public boolean dropCourse(Course c) { + // TODO: Remove the course from the student's list + // Restore the course capacity if removal was successful + // Return true if the course was dropped, otherwise false + return false; + } + + public void showRegisteredCourses() { + // TODO: Print all registered courses + } +} \ No newline at end of file