From e1dcec6f08bf3c5a1bdc570ab814b3a248de3bbc Mon Sep 17 00:00:00 2001 From: Anant Shanker Date: Wed, 10 Apr 2024 18:03:11 +0800 Subject: [PATCH] Resolve attendance display --- src/main/java/seedu/address/logic/Messages.java | 8 +++++++- .../seedu/address/logic/commands/EditPersonCommand.java | 2 -- .../java/seedu/address/model/weeknumber/WeekNumber.java | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 507a1958667..1b3ca134a03 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -102,7 +102,13 @@ public static String format(Person person) { .append("; Major: ") .append(person.getMajor()) .append("; Attendance: "); - person.getAttendance().forEach(builder::append); + String combinedString = person.getAttendance().stream() + .map(weekNumber -> weekNumber.toString() + ", ") + .collect(Collectors.joining()); + if (!combinedString.isEmpty()) { + combinedString = combinedString.substring(0, combinedString.length() - 2); + } + builder.append(combinedString); builder.append("; Tags: "); person.getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/logic/commands/EditPersonCommand.java b/src/main/java/seedu/address/logic/commands/EditPersonCommand.java index 92cbecd6fc7..11e160c139c 100644 --- a/src/main/java/seedu/address/logic/commands/EditPersonCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditPersonCommand.java @@ -116,7 +116,6 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript return new Person(updatedName, updatedPhone, updatedEmail, updatedNusNet, updatedMajor, updatedAttendance, updatedTags); } - @Override public boolean equals(Object other) { if (other == this) { @@ -169,7 +168,6 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setAttendance(toCopy.attendance); setTags(toCopy.tags); } - /** * Returns true if at least one field is edited. */ diff --git a/src/main/java/seedu/address/model/weeknumber/WeekNumber.java b/src/main/java/seedu/address/model/weeknumber/WeekNumber.java index 21eb389e133..c557c9a741b 100644 --- a/src/main/java/seedu/address/model/weeknumber/WeekNumber.java +++ b/src/main/java/seedu/address/model/weeknumber/WeekNumber.java @@ -51,6 +51,6 @@ public int hashCode() { } @Override public String toString() { - return "[" + value.toString() + "]"; + return value.toString(); } }