diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index 19c65e4..03aa389 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -14,6 +14,38 @@ public class Administration { private List courses; Scanner scanner = new Scanner(System.in); + public List getProfessors() { + return professors; + } + + public void setProfessors(List professors) { + this.professors = professors; + } + + public List getAdmins() { + return admins; + } + + public void setAdmins(List admins) { + this.admins = admins; + } + + public List getStudents() { + return students; + } + + public void setStudents(List students) { + this.students = students; + } + + public List getCourses() { + return courses; + } + + public void setCourses(List courses) { + this.courses = courses; + } + /** * Constructor */ @@ -355,6 +387,25 @@ public class Administration { } return false; } + public void initializeDummyData(){ + Student student1 = new Student("Mark", "S1001", "Student"); + Student student2 = new Student("Gustavo", "S1002", "Student"); + this.addStudents(student1); + this.addStudents(student2); + Professor prof1 = new Professor("Joachim", "P1001", "Professor"); + Professor prof2 = new Professor("Herbert", "P1002", "Professor"); + this.addProfessor(prof1); + this.addProfessor(prof2); + Admin admin1 = new Admin ("Peter", "A1001", "Admin"); + Admin admin2 = new Admin ("Martin", "A1002", "Admin"); + this.addAdmin(admin1); + this.addAdmin(admin2); + Course course1 = new Course("MathDUMMY", "CDUMMY1", 5); + Course course2 = new Course("EnglishDUMMY", "CDUMMY2", 6); + this.addCourse(course1); + this.addCourse(course2); + + } } diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java index f796f26..e7a9a57 100644 --- a/src/main/java/org/example/Main.java +++ b/src/main/java/org/example/Main.java @@ -48,32 +48,16 @@ public class Main { break; case 7: - System.out.println("Dummy data initialized."); - - Student student1 = new Student("Mark", "S1001", "Student"); - Student student2 = new Student("Sebastian", "S1002", "Student"); - administration.addStudents(student1); - administration.addStudents(student2); - Professor prof1 = new Professor("Joachim", "P1001", "Professor"); - Professor prof2 = new Professor("Herbert", "P1002", "Professor"); - administration.addProfessor(prof1); - administration.addProfessor(prof2); - Admin admin1 = new Admin ("Peter", "A1001", "Admin"); - Admin admin2 = new Admin ("Martin", "A1002", "Admin"); - administration.addAdmin(admin1); - administration.addAdmin(admin2); - Course.addCourse("Math", "C1001", 5, "courseData.txt"); - Course.addCourse("English", "C1002", 6, "courseData.txt"); - - DummyDataExists = true; + if(!DummyDataExists){ + administration.initializeDummyData(); + System.out.println("Dummy data initialized."); + } + else{System.out.println("Dummy Data could already exists");} break; case 8: - if (DummyDataExists){ - Course.deleteCourse("courseData.txt"); - Course.deleteCourse("courseData.txt"); - } + exit = true; System.out.println("Exiting..."); break; diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index 6f24b85..1dc593f 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -287,4 +287,22 @@ class AdministrationTest { // Finding the added course assertEquals(course, admin.findCourseByID("M101")); } -} \ No newline at end of file + @Test + public void testInitializeDummyData(){ + admin.initializeDummyData(); + + // Check if students are initialized correctly + assertEquals(2, admin.getStudents().size()); + + // Check if professors are initialized correctly + assertEquals(2, admin.getProfessors().size()); + + // Check if admins are initialized correctly + assertEquals(2, admin.getAdmins().size()); + + // Check if courses are initialized correctly + assertEquals(2, admin.getCourses().size()); + } + + + }