Completed the Registration System (With Bonus).
This commit is contained in:
Generated
+1
@@ -0,0 +1 @@
|
||||
Student.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package CourseRegistrationStarter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class RegistrationSystem {
|
||||
private ArrayList<Course> courses;
|
||||
@@ -9,16 +10,44 @@ public class RegistrationSystem {
|
||||
}
|
||||
|
||||
public void addCourseToSystem(Course c) {
|
||||
// TODO: Add the course to the system
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
String courseName = scanner.next();
|
||||
String courseCode = scanner.next();
|
||||
int capacity = scanner.nextInt();
|
||||
|
||||
Course newCourse = new Course(courseName, courseCode, capacity);
|
||||
courses.add(newCourse);
|
||||
}
|
||||
|
||||
public Course findCourseByCode(String code) {
|
||||
// TODO: Search for a course by course code
|
||||
// Return the matching course if found, otherwise return null
|
||||
for (Course i : courses)
|
||||
{
|
||||
if (i.getCourseCode().equals(code))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Course findCourseByName(String name) {
|
||||
for (Course i : courses)
|
||||
{
|
||||
if (i.getCourseCode().equals(name))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void showAllCourses() {
|
||||
// TODO: Print all courses in the system
|
||||
for (Course i : courses)
|
||||
{
|
||||
System.out.println(i.getCourseName());
|
||||
System.out.println(i.getCourseCode());
|
||||
System.out.println(i.getCapacity());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,7 @@ public class Student {
|
||||
}
|
||||
|
||||
public boolean addCourse(Course c) {
|
||||
// TODO: Register the student in the course if capacity allows
|
||||
// Return true if registration was successful, otherwise false
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user