finishing TODO parts

This commit is contained in:
2026-04-20 23:15:32 +03:30
parent 8ddd529c85
commit 8f1cd0d721
3 changed files with 43 additions and 0 deletions
@@ -21,12 +21,26 @@ public class Student {
}
public boolean addCourse(Course c) {
if(registeredCourses.contains(c))
return false;
if((c.getCapacity() > 0)){
this.registeredCourses.add(c);
c.reduceCapacity();
return true;
}
// 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) {
for(int i = 0; i < this.registeredCourses.size(); i++){
if (this.registeredCourses.get(i) == c){
this.registeredCourses.remove(c);
c.increaseCapacity();
return true;
}
}
// 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
@@ -34,6 +48,9 @@ public class Student {
}
public void showRegisteredCourses() {
for(int i = 0; i < registeredCourses.size(); i++){
System.out.println(this.registeredCourses.get(i).getCourseName() + ", code: " + this.registeredCourses.get(i).getCourseCode());
}
// TODO: Print all registered courses
}
}