|
|
@ -2,6 +2,7 @@ package org.example; |
|
|
|
import java.io.*; |
|
|
|
import java.util.List; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -161,4 +162,27 @@ public class Course { |
|
|
|
} |
|
|
|
return false; // No course with the same name or code found |
|
|
|
} |
|
|
|
|
|
|
|
public static void addCourseFromUserInput(String filename) { |
|
|
|
Scanner scanner = new Scanner(System.in); |
|
|
|
|
|
|
|
System.out.print("Enter the name of the course: "); |
|
|
|
String courseName = scanner.nextLine(); |
|
|
|
System.out.print("Enter the code of the course: "); |
|
|
|
String courseCode = scanner.nextLine(); |
|
|
|
|
|
|
|
// Check if the course already exists |
|
|
|
if (courseExists(filename, courseName, courseCode)) { |
|
|
|
System.out.println("Course with the same name or code already exists."); |
|
|
|
return; |
|
|
|
} |
|
|
|
System.out.print("Enter the credit value of the course: "); |
|
|
|
int courseCredit = scanner.nextInt(); |
|
|
|
|
|
|
|
// Add the course using the provided data |
|
|
|
addCourse(courseName, courseCode, courseCredit, filename); |
|
|
|
|
|
|
|
System.out.println("Added Course successfully!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |