fix: update src/Main.java and vcs.xml
This commit is contained in:
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
+72
-25
@@ -2,46 +2,93 @@ import java.util.Scanner;
|
||||
|
||||
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 studentId = input.nextLine();
|
||||
System.out.print("Enter student id: ");
|
||||
String id = input.nextLine();
|
||||
|
||||
Student s1 = new Student(name, studentId);
|
||||
Student student = new Student(name, id);
|
||||
|
||||
// ساخت 3 درس
|
||||
Course c1 = new Course("Advanced Programming", "AP1404", 2);
|
||||
Course c2 = new Course("Data Structures", "DS1404", 1);
|
||||
Course c3 = new Course("Database Systems", "DB1404", 3);
|
||||
int choice = 0;
|
||||
|
||||
// ساخت سیستم ثبت نام
|
||||
RegistrationSystem sys = new RegistrationSystem();
|
||||
while (choice != 5)
|
||||
{
|
||||
|
||||
// اضافه کردن درسها به سیستم
|
||||
sys.addCourseToSystem(c1);
|
||||
sys.addCourseToSystem(c2);
|
||||
sys.addCourseToSystem(c3);
|
||||
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");
|
||||
|
||||
// ثبتنام خودکار دانشآموز
|
||||
s1.addCourse(c1);
|
||||
s1.addCourse(c2);
|
||||
System.out.print("Choice: ");
|
||||
choice = input.nextInt();
|
||||
input.nextLine();
|
||||
|
||||
// حذف یکی از درسها
|
||||
s1.dropCourse(c2);
|
||||
switch (choice)
|
||||
{
|
||||
|
||||
// نمایش درسهای ثبتشده
|
||||
System.out.println("\nFinal registered courses:");
|
||||
s1.showRegisteredCourses();
|
||||
case 1:
|
||||
system.showAllCourses();
|
||||
break;
|
||||
|
||||
// نمایش ظرفیت باقیماندهی همه درسها
|
||||
System.out.println("\nRemaining course capacities:");
|
||||
sys.showAllCourses();
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user