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
+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
}
}