Browse Source

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

remotes/origin/fdai7887
fdai7887 11 months ago
parent
commit
81bc1b5118
  1. 4
      src/main/java/org/example/Administration.java
  2. 19
      src/test/java/org/example/StudentTest.java

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

@ -507,9 +507,9 @@ public class Administration {
} }
public void enrollStudentInCourseInteractive() { public void enrollStudentInCourseInteractive() {
System.out.println("Enter Student ID:");
System.out.print("Enter Student ID:");
String studentId = scanner.nextLine(); // Use nextLine for consistent input handling String studentId = scanner.nextLine(); // Use nextLine for consistent input handling
System.out.println("Enter Course ID:");
System.out.print("Enter Course ID:");
String courseId = scanner.nextLine(); String courseId = scanner.nextLine();
boolean enrolled = enrollStudentInCourse(studentId, courseId); boolean enrolled = enrollStudentInCourse(studentId, courseId);

19
src/test/java/org/example/StudentTest.java

@ -87,6 +87,25 @@ class StudentTest {
} }
@Test
void testAssignGrade() {
Student student = new Student("John Doe", "S1001", "Student");
Course course = new Course("Introduction to Java", "C101", 3); // Assuming your Course class has a constructor that accepts name, ID, and credits
// Pre-assignment check: Ensure the course is not already graded
assertNull(student.getCourseGrades().get(course), "Course should not have a grade assigned before test.");
// Assign a grade to the course
String grade = "A";
student.assignGrade(course, grade);
// Post-assignment check: Ensure the grade is correctly assigned
assertEquals(grade, student.getCourseGrades().get(course), "Grade assigned to course does not match expected grade.");
// Optional: Test changing the grade
String newGrade = "B";
student.assignGrade(course, newGrade);
assertEquals(newGrade, student.getCourseGrades().get(course), "Grade update for course does not match expected new grade.");
}
} }
Loading…
Cancel
Save