diff --git a/src/main/java/seedu/address/model/student/Lesson.java b/src/main/java/seedu/address/model/student/Lesson.java index 97520dc1810..ad972ff14de 100644 --- a/src/main/java/seedu/address/model/student/Lesson.java +++ b/src/main/java/seedu/address/model/student/Lesson.java @@ -146,6 +146,6 @@ public int hashCode() { * Format state as text for viewing. */ public String toString() { - return '[' + value + ']'; + return this.subject + " " + this.date.toString() + " " + this.time; } } diff --git a/src/main/java/seedu/address/ui/StudentCard.java b/src/main/java/seedu/address/ui/StudentCard.java index 6c5eb47735e..4512d018402 100644 --- a/src/main/java/seedu/address/ui/StudentCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -60,7 +60,7 @@ public StudentCard(Student student, int displayedIndex) { subject.setText(student.getSubject().value); remark.setText(student.getRemark().value); student.getLessons().stream() - .sorted(Comparator.comparing(Lesson::getLessonValue)) - .forEach(lesson -> lessons.getChildren().add(new Label(lesson.getLessonValue()))); + .sorted(Comparator.comparing(Lesson::getLessonValue)).filter(lesson -> lesson.getLessonStatus() == 0) + .forEach(lesson -> lessons.getChildren().add(new Label(lesson.toString()))); } } diff --git a/src/test/java/seedu/address/model/student/LessonTest.java b/src/test/java/seedu/address/model/student/LessonTest.java index a343c976b91..e67cb1cf638 100644 --- a/src/test/java/seedu/address/model/student/LessonTest.java +++ b/src/test/java/seedu/address/model/student/LessonTest.java @@ -56,4 +56,19 @@ public void equals() { // different values -> returns false assertFalse(lesson.equals(new Lesson("Science|01-01-2023|09:00|0"))); } + + @Test + public void getLessonStatusIsValid() { + Lesson lesson1 = new Lesson("Math|01-01-2023|09:00|0"); + assertEquals(lesson1.getLessonStatus(), 0); + + Lesson lesson2 = new Lesson("Math|01-01-2023|09:00|1"); + assertEquals(lesson2.getLessonStatus(), 1); + } + + @Test + public void toStringTest() { + Lesson lesson = new Lesson("Math|01-01-2023|09:00|0"); + assertEquals(lesson.toString(), "Math 2023-01-01 09:00"); + } }