add course registration starter code

This commit is contained in:
2026-04-16 19:37:41 +03:30
parent ef4cbfda4d
commit ecc46eadc1
7 changed files with 338 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
+51
View File
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="da4479e4-5893-429c-af14-cd1d2f0491e0" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
<ProjectState />
</projectState>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 2
}</component>
<component name="ProjectId" id="3CRfLUp4u7tybkWCsJp9IJJ6XtS" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "course-registration",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/User/Desktop/AP/WS-02-intro-to-oop/CourseRegistrationSystem",
"onboarding.tips.debug.path": "C:/Users/User/Desktop/AP/WS-02-intro-to-oop/CourseRegistrationSystem/src/main/java/org/to/Main.java"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="da4479e4-5893-429c-af14-cd1d2f0491e0" name="Changes" comment="" />
<created>1776353250476</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1776353250476</updated>
</task>
<servers />
</component>
</project>
+167
View File
@@ -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<Course>`
- 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
+37
View File
@@ -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++;
}
}
+14
View File
@@ -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
}
}
@@ -0,0 +1,24 @@
package CourseRegistrationStarter;
import java.util.ArrayList;
public class RegistrationSystem {
private ArrayList<Course> 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
}
}
@@ -0,0 +1,39 @@
package CourseRegistrationStarter;
import java.util.ArrayList;
public class Student {
private String name;
private String studentId;
private ArrayList<Course> 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
}
}