From 567bfb0e4670530de00f8c5a2b32c477349e815b Mon Sep 17 00:00:00 2001 From: sikai00 Date: Thu, 13 Oct 2022 16:01:55 +0800 Subject: [PATCH 1/2] Fix plurality of records --- .../java/seedu/address/ui/ClientListPanel.java | 15 +++++++++++++-- .../java/seedu/address/ui/MeetingListPanel.java | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/ui/ClientListPanel.java b/src/main/java/seedu/address/ui/ClientListPanel.java index 7d33fee1dfe..a708c1015ef 100644 --- a/src/main/java/seedu/address/ui/ClientListPanel.java +++ b/src/main/java/seedu/address/ui/ClientListPanel.java @@ -32,9 +32,20 @@ public ClientListPanel(ObservableList clientList) { super(FXML); clientListView.setItems(clientList); clientListView.setCellFactory(listView -> new PersonListViewCell()); - numClients.setText(Integer.toString(clientList.size()) + " Records"); + numClients.setText(numClientsString(clientList)); clientList.addListener((ListChangeListener) - c -> numClients.setText(Integer.toString(clientList.size()) + " Records")); + c -> numClients.setText(numClientsString(clientList))); + } + + /** + * Returns a string denoting the number of records for {@code Client} currently shown in the {@code clientList}. + */ + private String numClientsString(ObservableList clientList) { + if (clientList.size() == 1) { + return "1 record"; + } else { + return clientList.size() + " records"; + } } /** diff --git a/src/main/java/seedu/address/ui/MeetingListPanel.java b/src/main/java/seedu/address/ui/MeetingListPanel.java index e19478404f5..512789bcec7 100644 --- a/src/main/java/seedu/address/ui/MeetingListPanel.java +++ b/src/main/java/seedu/address/ui/MeetingListPanel.java @@ -10,6 +10,7 @@ import javafx.scene.control.ListView; import javafx.scene.layout.Region; import seedu.address.commons.core.LogsCenter; +import seedu.address.model.client.Client; import seedu.address.model.meeting.Meeting; /** @@ -32,9 +33,20 @@ public MeetingListPanel(ObservableList meetingList) { super(FXML); meetingListView.setItems(meetingList); meetingListView.setCellFactory(listView -> new MeetingListViewCell()); - numMeetings.setText(Integer.toString(meetingList.size()) + " Records"); + numMeetings.setText(numMeetingsString(meetingList)); meetingList.addListener((ListChangeListener) - c -> numMeetings.setText(Integer.toString(meetingList.size()) + " Records")); + c -> numMeetings.setText(numMeetingsString(meetingList))); + } + + /** + * Returns a string denoting the number of records for {@code Meeting} currently shown in the {@code meetingList}. + */ + private String numMeetingsString(ObservableList meetingList) { + if (meetingList.size() == 1) { + return "1 record"; + } else { + return meetingList.size() + " records"; + } } /** From 6c44db7f419240caed1c247c817ceedce007b6f1 Mon Sep 17 00:00:00 2001 From: sikai00 Date: Fri, 14 Oct 2022 16:53:53 +0800 Subject: [PATCH 2/2] Fix checkstyle --- src/main/java/seedu/address/ui/MeetingListPanel.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/address/ui/MeetingListPanel.java b/src/main/java/seedu/address/ui/MeetingListPanel.java index 512789bcec7..1bf5e15064a 100644 --- a/src/main/java/seedu/address/ui/MeetingListPanel.java +++ b/src/main/java/seedu/address/ui/MeetingListPanel.java @@ -10,7 +10,6 @@ import javafx.scene.control.ListView; import javafx.scene.layout.Region; import seedu.address.commons.core.LogsCenter; -import seedu.address.model.client.Client; import seedu.address.model.meeting.Meeting; /**