Skip to content

Commit

Permalink
Merge pull request #150 from sikai00/fix-single-record-numclient
Browse files Browse the repository at this point in the history
Fix plurality of records
  • Loading branch information
sikai00 authored Oct 14, 2022
2 parents 4525d4c + 6c44db7 commit ae1f85a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/main/java/seedu/address/ui/ClientListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@ public ClientListPanel(ObservableList<Client> 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<? super Client>)
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<Client> clientList) {
if (clientList.size() == 1) {
return "1 record";
} else {
return clientList.size() + " records";
}
}

/**
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/seedu/address/ui/MeetingListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@ public MeetingListPanel(ObservableList<Meeting> 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<? super Meeting>)
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<Meeting> meetingList) {
if (meetingList.size() == 1) {
return "1 record";
} else {
return meetingList.size() + " records";
}
}

/**
Expand Down

0 comments on commit ae1f85a

Please sign in to comment.