-
Notifications
You must be signed in to change notification settings - Fork 166
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
[W5.7][F11-1]Wu Jiacheng #440
base: master
Are you sure you want to change the base?
Changes from 7 commits
38cb36c
fe4e386
8338333
02d210d
120f13f
72d276c
02f35fc
48ed814
8ebf3d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package seedu.addressbook.commands; | ||
|
||
/** | ||
* display the total number of persons stored in the address book | ||
*/ | ||
public class TotalCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "total"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": display the total number of persons stored in the address book.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! I did not think of explaining what the |
||
|
||
public static final String MESSAGE_TOTAL_IN_ADDRESSBOOK = "There is/are %1$s person(s) in the address book"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I liked your usage of %1$s in the |
||
|
||
@Override | ||
public CommandResult execute() { | ||
return new CommandResult(String.format(MESSAGE_TOTAL_IN_ADDRESSBOOK, addressBook.getTotal())); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,11 @@ public void removePerson(ReadOnlyPerson toRemove) throws PersonNotFoundException | |
allPersons.remove(toRemove); | ||
} | ||
|
||
/** | ||
* Gets total number of persons in list. | ||
*/ | ||
public int getTotal() { return allPersons.getSize(); } | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice naming of getter method as |
||
/** | ||
* Clears all persons and tags from the address book. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,11 @@ public void remove(ReadOnlyPerson toRemove) throws PersonNotFoundException { | |
} | ||
} | ||
|
||
/** | ||
* Gets total number of persons in list. | ||
*/ | ||
public int getSize() { return internalList.size(); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting issue, please check coding standard |
||
|
||
/** | ||
* Clears all persons in list. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,6 +290,21 @@ | |
|| | ||
|| 2 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: list] | ||
|| 1. Betsy Choo Tags: [secretive] | ||
|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| | ||
|| 2 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: total] | ||
|| There is/are 2 person(s) in the address book | ||
|| =================================================== | ||
|| Enter command: || [Command entered: delete 1] | ||
|| Deleted Person: Betsy Choo Phone: (private) 222222 Email: (private) [email protected] Address: (private) 222, beta street Tags: [secretive] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: total] | ||
|| There is/are 1 person(s) in the address book | ||
|| =================================================== | ||
|| Enter command: || [Command entered: clear] | ||
|| Address book has been cleared! | ||
|| =================================================== | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the format for
total
commandlist
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a error. Thanks for pointing it out.