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 class Main
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
Scanner input = new Scanner(System.in);
|
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: ");
|
System.out.print("Enter student name: ");
|
||||||
String name = input.nextLine();
|
String name = input.nextLine();
|
||||||
|
|
||||||
System.out.print("Enter student ID: ");
|
System.out.print("Enter student id: ");
|
||||||
String studentId = input.nextLine();
|
String id = input.nextLine();
|
||||||
|
|
||||||
Student s1 = new Student(name, studentId);
|
Student student = new Student(name, id);
|
||||||
|
|
||||||
// ساخت 3 درس
|
int choice = 0;
|
||||||
Course c1 = new Course("Advanced Programming", "AP1404", 2);
|
|
||||||
Course c2 = new Course("Data Structures", "DS1404", 1);
|
|
||||||
Course c3 = new Course("Database Systems", "DB1404", 3);
|
|
||||||
|
|
||||||
// ساخت سیستم ثبت نام
|
while (choice != 5)
|
||||||
RegistrationSystem sys = new RegistrationSystem();
|
{
|
||||||
|
|
||||||
// اضافه کردن درسها به سیستم
|
System.out.println("\n--- MENU ---");
|
||||||
sys.addCourseToSystem(c1);
|
System.out.println("1. Show all courses");
|
||||||
sys.addCourseToSystem(c2);
|
System.out.println("2. Register course");
|
||||||
sys.addCourseToSystem(c3);
|
System.out.println("3. Drop course");
|
||||||
|
System.out.println("4. Show my courses");
|
||||||
|
System.out.println("5. Exit");
|
||||||
|
|
||||||
// ثبتنام خودکار دانشآموز
|
System.out.print("Choice: ");
|
||||||
s1.addCourse(c1);
|
choice = input.nextInt();
|
||||||
s1.addCourse(c2);
|
input.nextLine();
|
||||||
|
|
||||||
// حذف یکی از درسها
|
switch (choice)
|
||||||
s1.dropCourse(c2);
|
{
|
||||||
|
|
||||||
// نمایش درسهای ثبتشده
|
case 1:
|
||||||
System.out.println("\nFinal registered courses:");
|
system.showAllCourses();
|
||||||
s1.showRegisteredCourses();
|
break;
|
||||||
|
|
||||||
// نمایش ظرفیت باقیماندهی همه درسها
|
case 2:
|
||||||
System.out.println("\nRemaining course capacities:");
|
System.out.print("Enter course code: ");
|
||||||
sys.showAllCourses();
|
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