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

Add option to pay all persons in PayCommand #102

Merged
merged 5 commits into from
Oct 28, 2021

Conversation

szelongq
Copy link

Add an option to pay all persons in the current list rather than just one person using PayCommand (resolves #101).

@szelongq szelongq added the priority.MEDIUM Medium priority issue label Oct 27, 2021
@szelongq szelongq added this to the v1.3 milestone Oct 27, 2021
Copy link

@danielsimre danielsimre left a comment

Choose a reason for hiding this comment

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

Some minor edits and clarifications on the code required.

@@ -24,43 +26,98 @@
import seedu.address.model.tag.Tag;

/**
* Pays a person identified using it's displayed index from the address book.
* Pays a person identified using it's displayed index or all persons in the current list from the address book.

Choose a reason for hiding this comment

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

Minor nitpick, but would "Pays a person using their displayed index, or all persons..." be a clearer description?


/**
* Constructor for paying all persons in the list.

Choose a reason for hiding this comment

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

Should this header comment be of the form "Creates..." (Code Quality for comments) instead?

}

/**
* Constructor for paying a specific person in the list.

Choose a reason for hiding this comment

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

Similar to the above constructor, should the header comment be of the form "Creates..." (Code Quality for comments) instead?

Copy link
Author

Choose a reason for hiding this comment

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

I have updated the comment, thanks!


// Pay all persons in the list
for (Person personToPay: lastShownList) {
Person paidPerson = createPaidPerson(personToPay);

Choose a reason for hiding this comment

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

Similar to above, should there be a check to see if the person is actually pending payment?

throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Person personToPay = lastShownList.get(targetIndex.getZeroBased());
// Pay the person of the specified index
Person personToPay = lastShownList.get(targetIndex.get().getZeroBased());
Person paidPerson = createPaidPerson(personToPay);

Choose a reason for hiding this comment

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

Could this be a potential bug, since there does not seem to be a check if the person is pending payment? (So it is possible that someone who is already paid gets paid again)

Copy link
Author

Choose a reason for hiding this comment

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

I missed that, thanks for pointing that out! I have added a validity check regarding already paid persons.

Copy link

@danielsimre danielsimre left a comment

Choose a reason for hiding this comment

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

LGTM!

@danielsimre danielsimre merged commit e3aa44b into AY2122S1-CS2103T-F11-3:master Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.MEDIUM Medium priority issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to pay all persons in PayCommand
2 participants