From efcb580982670121dd487932aa805f0451ce059f Mon Sep 17 00:00:00 2001 From: leepoeaik Date: Mon, 25 Mar 2024 19:33:53 +0800 Subject: [PATCH 1/4] update lesson labels to not display when completed --- src/main/java/seedu/address/model/student/Lesson.java | 2 +- src/main/java/seedu/address/ui/StudentCard.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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..35476508877 100644 --- a/src/main/java/seedu/address/ui/StudentCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -61,6 +61,7 @@ public StudentCard(Student student, int displayedIndex) { remark.setText(student.getRemark().value); student.getLessons().stream() .sorted(Comparator.comparing(Lesson::getLessonValue)) - .forEach(lesson -> lessons.getChildren().add(new Label(lesson.getLessonValue()))); + .filter(x -> x.getLessonStatus() == 0) + .forEach(lesson -> lessons.getChildren().add(new Label(lesson.toString()))); } } From ff1347da81f98a565d6980b3c1a4dd3e2bf9eb1f Mon Sep 17 00:00:00 2001 From: leepoeaik Date: Mon, 25 Mar 2024 19:46:26 +0800 Subject: [PATCH 2/4] Fix codecov issues --- .../java/seedu/address/model/student/LessonTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/seedu/address/model/student/LessonTest.java b/src/test/java/seedu/address/model/student/LessonTest.java index a343c976b91..a481bbbef64 100644 --- a/src/test/java/seedu/address/model/student/LessonTest.java +++ b/src/test/java/seedu/address/model/student/LessonTest.java @@ -56,4 +56,13 @@ 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); + } } From 6a47a65a79854547e7017d2bdf70eca8d2d6e371 Mon Sep 17 00:00:00 2001 From: leepoeaik Date: Mon, 25 Mar 2024 20:26:10 +0800 Subject: [PATCH 3/4] Fix codecov issues --- src/main/java/seedu/address/ui/StudentCard.java | 2 +- src/test/java/seedu/address/model/student/LessonTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/ui/StudentCard.java b/src/main/java/seedu/address/ui/StudentCard.java index 35476508877..0e47ef895ea 100644 --- a/src/main/java/seedu/address/ui/StudentCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -61,7 +61,7 @@ public StudentCard(Student student, int displayedIndex) { remark.setText(student.getRemark().value); student.getLessons().stream() .sorted(Comparator.comparing(Lesson::getLessonValue)) - .filter(x -> x.getLessonStatus() == 0) + .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 a481bbbef64..e67cb1cf638 100644 --- a/src/test/java/seedu/address/model/student/LessonTest.java +++ b/src/test/java/seedu/address/model/student/LessonTest.java @@ -65,4 +65,10 @@ public void getLessonStatusIsValid() { 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"); + } } From ece91b3ee2c8ea8c52d403cb296b378982a2e26d Mon Sep 17 00:00:00 2001 From: leepoeaik Date: Mon, 25 Mar 2024 21:17:35 +0800 Subject: [PATCH 4/4] Fix codecov issues --- src/main/java/seedu/address/ui/StudentCard.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/ui/StudentCard.java b/src/main/java/seedu/address/ui/StudentCard.java index 0e47ef895ea..4512d018402 100644 --- a/src/main/java/seedu/address/ui/StudentCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -60,8 +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)) - .filter(lesson -> lesson.getLessonStatus() == 0) + .sorted(Comparator.comparing(Lesson::getLessonValue)).filter(lesson -> lesson.getLessonStatus() == 0) .forEach(lesson -> lessons.getChildren().add(new Label(lesson.toString()))); } }