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