Browse Source

Merge branch 'master' of https://gitlab.cs.hs-fulda.de/fdai7600/PWN_Alpha_Dogs into fdai7780

remotes/origin/fdai7780
Tobias Herbert 11 months ago
parent
commit
5074142b4f
  1. 51
      src/main/java/org/example/Administration.java
  2. 28
      src/main/java/org/example/Main.java
  3. 20
      src/test/java/org/example/AdministrationTest.java

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

@ -14,6 +14,38 @@ public class Administration {
private List<Course> courses;
Scanner scanner = new Scanner(System.in);
public List<Professor> getProfessors() {
return professors;
}
public void setProfessors(List<Professor> professors) {
this.professors = professors;
}
public List<Admin> getAdmins() {
return admins;
}
public void setAdmins(List<Admin> admins) {
this.admins = admins;
}
public List<Student> getStudents() {
return students;
}
public void setStudents(List<Student> students) {
this.students = students;
}
public List<Course> getCourses() {
return courses;
}
public void setCourses(List<Course> 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);
}
}

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;

20
src/test/java/org/example/AdministrationTest.java

@ -287,4 +287,22 @@ class AdministrationTest {
// Finding the added course
assertEquals(course, admin.findCourseByID("M101"));
}
}
@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());
}
}
Loading…
Cancel
Save