Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update lesson labels to not display when completed #56

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/student/Lesson.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/ui/StudentCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
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())));

Check warning on line 64 in src/main/java/seedu/address/ui/StudentCard.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/ui/StudentCard.java#L64

Added line #L64 was not covered by tests

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't think of this, amazing!

}
}
15 changes: 15 additions & 0 deletions src/test/java/seedu/address/model/student/LessonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Loading