Skip to content

Commit

Permalink
Fix number of CCA members not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
jovyntls committed Oct 18, 2021
1 parent 1142020 commit d48e066
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public CommandResult execute(Model model) throws CommandException {

boolean success = model.enrolPersonIntoCca(ccaToEnrolInto, personToEnrol);
if (success) {
model.setCca(ccaToEnrolInto, ccaToEnrolInto);
model.updateFilteredCcaList(Model.PREDICATE_SHOW_ALL_CCAS);
return new CommandResult(String.format(MESSAGE_SUCCESS, personToEnrol.getName(), ccaToEnrolInto.getName()));
} else {
throw new CommandException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import seedu.address.model.person.Person;

public class CcaExpelCommand extends Command {

public static final String COMMAND_WORD = "expel";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Expels a person from a CCA. "
Expand Down Expand Up @@ -71,6 +72,8 @@ public CommandResult execute(Model model) throws CommandException {

boolean success = model.expelPersonFromCca(ccaToExpelFrom, personToExpel);
if (success) {
model.setCca(ccaToExpelFrom, ccaToExpelFrom);
model.updateFilteredCcaList(Model.PREDICATE_SHOW_ALL_CCAS);
return new CommandResult(String.format(MESSAGE_SUCCESS, personToExpel.getName(), ccaToExpelFrom.getName()));
} else {
throw new CommandException(
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/seedu/address/model/cca/Cca.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public Set<Person> getPersonArrayList() {
return personArrayList;
}

/**
* Returns the number of people in this CCA.
* @return the number of members of this CCA
*/
public int getNumberOfMembers() {
return personArrayList.size();
}

/**
* Returns the cid of this CCA.
* @return the cid of this CCA
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/CcaCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CcaCard(Cca cca, int displayedIndex) {
this.cca = cca;
id.setText(displayedIndex + ". ");
this.name.setText(cca.getName().fullName);
this.numPeople.setText("No. of people: 3");
this.numPeople.setText("No. of people: " + cca.getNumberOfMembers());

// can consider having tags for CCAs
Label tempLabel = new Label("Music");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/ui/CcaListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.cca.Cca;

/**
* Panel containing the list of CCAs.
*/
public class CcaListPanel extends UiPart<Region> {
private static final String FXML = "CcaListPanel.fxml";
private final Logger logger = LogsCenter.getLogger(CcaListPanel.class);
Expand Down

0 comments on commit d48e066

Please sign in to comment.