Browse Source

refactoring: moving initializeDummyData to Administration class

remotes/origin/fdai7780
fdai7887 11 months ago
parent
commit
1765943f6b
  1. 19
      src/main/java/org/example/Administration.java
  2. 28
      src/main/java/org/example/Main.java

19
src/main/java/org/example/Administration.java

@ -359,6 +359,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);
}
}

28
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;

Loading…
Cancel
Save