Files
WS-02-intro-to-oop/src/CourseRegistrationStarter/RegistrationSystem.java
T

44 lines
973 B
Java

package CourseRegistrationStarter;
import java.util.ArrayList;
public class RegistrationSystem {
private ArrayList<Course> courses;
public RegistrationSystem() {
courses = new ArrayList<>();
}
public void addCourseToSystem(Course c) {
courses.add(c);
}
public Course findCourseByCode(String code) {
for (Course a : courses)
{
if (a.getCourseCode().equals(code))
{
return a;
}
}
return null;
}
public Course findCourseByName(String name)
{
for (Course a : courses)
{
if (a.getCourseName().equals(name))
{
return a;
}
}
return null;
}
public void showAllCourses() {
for (Course c : courses)
{
System.out.println(c.getCourseName() + " - " + c.getCourseCode() + " - capacity: " + c.getCapacity());
}
}
}