diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index 0041c76..bbd7f83 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -196,7 +196,7 @@ public class Administration { */ public boolean deleteStudents(String studentID){ for(Student student : students){ - if(student.getId().equals(studentID)){ + if(student.getStudentId().equals(studentID)){ students.remove(student); return true; } @@ -223,7 +223,7 @@ public class Administration { { for(Student student :students) { - if(student.getId().equals(studentId)) + if(student.getStudentId().equals(studentId)) { return student; } diff --git a/src/main/java/org/example/Student.java b/src/main/java/org/example/Student.java index 5c4afe7..839a571 100644 --- a/src/main/java/org/example/Student.java +++ b/src/main/java/org/example/Student.java @@ -9,9 +9,9 @@ import java.util.List; */ public class Student { - String name; - String id; - String role; + String studentName; + String studentId; + String studentRole; public Student(){ @@ -25,33 +25,33 @@ public class Student { * @param role the role of the student in the system (should typically be "Student") */ - this.name = name; - this.id = id; - this.role = role; + this.studentName = name; + this.studentId = id; + this.studentRole = role; } - public String getName() { - return name; + public String getStudentName() { + return studentName; } - public String getId() { - return id; + public String getStudentId() { + return studentId; } - public String getRole() { - return role; + public String getStudentRole() { + return studentRole; } - public void setName(String name) { - this.name = name; + public void setStudentName(String studentName) { + this.studentName = studentName; } - public void setId(String id) { - this.id = id; + public void setStudentId(String studentId) { + this.studentId = studentId; } - public void setRole(String role) { - this.role = role; + public void setStudentRole(String studentRole) { + this.studentRole = studentRole; } /** @@ -61,15 +61,15 @@ public class Student { public void printStudentInfo() { - System.out.println("Name: " + getName()); - System.out.println("ID: " + getId()); - System.out.println("Role: " + getRole()); + System.out.println("Name: " + getStudentName()); + System.out.println("ID: " + getStudentId()); + System.out.println("Role: " + getStudentRole()); } public void writeToFile(Student student, String filename) throws IOException { try(BufferedWriter writer = new BufferedWriter(new FileWriter(filename))){ - String attributes = student.getName() + "\n" + student.getId() + "\n" + student.getRole(); + String attributes = student.getStudentName() + "\n" + student.getStudentId() + "\n" + student.getStudentRole(); writer.write(attributes); } diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index a98f761..047adaf 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -167,7 +167,7 @@ class AdministrationTest { // Now, the student should be found assertNotNull(administration.findStudentById("S1001")); - assertEquals("Alice", administration.findStudentById("S1001").getName()); + assertEquals("Alice", administration.findStudentById("S1001").getStudentName()); } @Test @@ -205,13 +205,13 @@ class AdministrationTest { assertNotNull(retrievedStudent); // Asserting that the retrieved student's name matches the expected name - assertEquals("Walter White", retrievedStudent.getName()); + assertEquals("Walter White", retrievedStudent.getStudentName()); // Asserting that the retrieved student's ID matches the expected ID - assertEquals("S123456", retrievedStudent.getId()); + assertEquals("S123456", retrievedStudent.getStudentId()); // Asserting that the retrieved student's role matches the expected role - assertEquals("Student", retrievedStudent.getRole()); + assertEquals("Student", retrievedStudent.getStudentRole()); } /** diff --git a/src/test/java/org/example/StudentTest.java b/src/test/java/org/example/StudentTest.java index 1e5f76f..1985b69 100644 --- a/src/test/java/org/example/StudentTest.java +++ b/src/test/java/org/example/StudentTest.java @@ -61,9 +61,9 @@ class StudentTest { assertEquals(1, testStudents.size()); Student admin = testStudents.get(0); - assertEquals("Sebastian Reichard", admin.getName()); - assertEquals("S1001", admin.getId()); - assertEquals("Student", admin.getRole()); + assertEquals("Sebastian Reichard", admin.getStudentName()); + assertEquals("S1001", admin.getStudentId()); + assertEquals("Student", admin.getStudentRole()); // Files.delete(Path.of(filename));