finishing TODO parts
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user