forked from ArefeRoosta/WS-02-intro-to-oop
62 lines
2.3 KiB
Java
62 lines
2.3 KiB
Java
package CourseRegistrationStarter;
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
Scanner scanner = new Scanner(System.in);
|
|
RegistrationSystem system = new RegistrationSystem();
|
|
|
|
|
|
system.addCourseToSystem(new Course("Advanced Programming", "CS101", 30));
|
|
system.addCourseToSystem(new Course("Data Structures", "CS102", 25));
|
|
system.addCourseToSystem(new Course("Database Systems", "CS103", 20));
|
|
|
|
|
|
System.out.print("Enter Student Name: ");
|
|
String sName = scanner.nextLine();
|
|
System.out.print("Enter Student ID: ");
|
|
String sId = scanner.nextLine();
|
|
Student student = new Student(sName, sId);
|
|
|
|
boolean running = true;
|
|
while (running) {
|
|
System.out.println("\n1. View All Courses\n2. Add Course\n3. Drop Course\n4. My Courses\n5. Exit");
|
|
System.out.print("Choice: ");
|
|
String choice = scanner.nextLine();
|
|
|
|
switch (choice) {
|
|
case "1":
|
|
system.showAllCourses();
|
|
break;
|
|
case "2":
|
|
System.out.print("Enter course code to add: ");
|
|
String addCode = scanner.nextLine();
|
|
Course toAdd = system.findCourseByCode(addCode);
|
|
if (toAdd != null) {
|
|
if (student.addCourse(toAdd)) System.out.println("Successfully added.");
|
|
} else {
|
|
System.out.println("Course not found!");
|
|
}
|
|
break;
|
|
case "3":
|
|
System.out.print("Enter course code to drop: ");
|
|
String dropCode = scanner.nextLine();
|
|
if (student.dropCourse(dropCode)) System.out.println("Successfully dropped.");
|
|
else System.out.println("You are not registered in this course.");
|
|
break;
|
|
case "4":
|
|
student.showRegisteredCourses();
|
|
break;
|
|
case "5":
|
|
running = false;
|
|
System.out.println("Exiting...");
|
|
break;
|
|
default:
|
|
System.out.println("Invalid option.");
|
|
}
|
|
}
|
|
scanner.close();
|
|
}
|
|
}
|