This commit is contained in:
2026-04-21 12:19:40 +03:30
parent 8ddd529c85
commit 00cbb1c0e4
5 changed files with 158 additions and 36 deletions
+91 -12
View File
@@ -1,14 +1,93 @@
package CourseRegistrationStarter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO:
// 1. Create at least 3 courses
// 2. Create 1 student
// 3. Create a registration system
// 4. Add courses to the system
// 5. Register the student in some courses
// 6. Drop one course
// 7. Print the final registered course list
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
// Courses
Course ap = new Course("Advanced Programming", "AP1404", 2);
Course ds = new Course("Data Structures", "DS2201", 1);
Course db = new Course("Database Systems", "DB3301", 3);
// System
RegistrationSystem system = new RegistrationSystem();
system.addCourseToSystem(ap);
system.addCourseToSystem(ds);
system.addCourseToSystem(db);
// Student
System.out.print("Enter student name: ");
String name = input.nextLine();
System.out.print("Enter student id: ");
String id = input.nextLine();
Student student = new Student(name, id);
int choice = 0;
while (choice != 5)
{
System.out.println("\n--- MENU ---");
System.out.println("1. Show all courses");
System.out.println("2. Register course");
System.out.println("3. Drop course");
System.out.println("4. Show my courses");
System.out.println("5. Exit");
System.out.print("Choice: ");
choice = input.nextInt();
input.nextLine();
switch (choice)
{
case 1:
system.showAllCourses();
break;
case 2:
System.out.print("Enter course code: ");
String regCode = input.nextLine();
Course c1 = system.findCourseByCode(regCode);
if (c1 != null)
{
student.addCourse(c1);
} else
{
System.out.println("Course not found");
}
break;
case 3:
System.out.print("Enter course code: ");
String dropCode = input.nextLine();
Course c2 = system.findCourseByCode(dropCode);
if (c2 != null)
{
student.dropCourse(c2);
} else
{
System.out.println("Course not found");
}
break;
case 4:
student.showRegisteredCourses();
break;
case 5:
System.out.println("Goodbye!");
break;
default:
System.out.println("Invalid choice");
}
}
}
}
}