|
|
@ -151,4 +151,14 @@ public class Course { |
|
|
|
Course course = new Course(); |
|
|
|
course.writeToFile(courseName, courseCode, courseCredit, filename); |
|
|
|
} |
|
|
|
|
|
|
|
private static boolean courseExists(String filename, String name, String code) { |
|
|
|
List<Course> courses = readFromFile(filename); |
|
|
|
for (Course course : courses) { |
|
|
|
if (course.getCourseName().equalsIgnoreCase(name) || course.getCourseCode().equalsIgnoreCase(code)) { |
|
|
|
return true; // Course with the same name or code already exists |
|
|
|
} |
|
|
|
} |
|
|
|
return false; // No course with the same name or code found |
|
|
|
} |
|
|
|
} |