complete Bonus methods
This commit is contained in:
@@ -9,7 +9,12 @@ public class RegistrationSystem {
|
||||
}
|
||||
|
||||
public void addCourseToSystem(Course c) {
|
||||
courses.add(c);
|
||||
if (courses.contains(c)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
courses.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
public Course findCourseByCode(String code) {
|
||||
@@ -26,4 +31,12 @@ public class RegistrationSystem {
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
public Course findCourseByName(String name) {
|
||||
for (Course c : courses) {
|
||||
if (c.getCourseName().equals(name)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,12 @@ public class Student {
|
||||
}
|
||||
|
||||
public boolean addCourse(Course c) {
|
||||
if (c.getCapacity() > 0 ) {
|
||||
registeredCourses.add(c);
|
||||
c.reduceCapacity();
|
||||
return true;
|
||||
if (registeredCourses.size() <= 3) {
|
||||
if (c.getCapacity() > 0) {
|
||||
registeredCourses.add(c);
|
||||
c.reduceCapacity();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user