-
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][T12-3]Thaddeus Lim #437
base: master
Are you sure you want to change the base?
Changes from all commits
13a0c6c
788a0b8
c692f3f
b251f4e
2ce2876
bb36418
227bbff
6ecc154
53634cd
dac73de
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 |
---|---|---|
|
@@ -156,6 +156,11 @@ Views all details of the 1st person in the results of the `find` command. | |
Clears all entries from the address book. + | ||
Format: `clear` | ||
|
||
== Counting total number of persons in the address book : `count` | ||
Counts total number of persons in the address book. | ||
Format: `count` | ||
|
||
|
||
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. Stray line break? Try to avoid these spaces by checking diff while submitting a PR. |
||
== Exiting the program : `exit` | ||
|
||
Exits the program. + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package seedu.addressbook.commands; | ||
|
||
/** | ||
* Shows total number of persons in address book. | ||
*/ | ||
public class CountCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "count"; | ||
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. Try to avoid public class member variables |
||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Counts the total number of contacts " | ||
+ "in the address book.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
|
||
public static final String MESSAGE_COUNTED = "Total number of persons in address book: %1$s"; | ||
|
||
@Override | ||
public CommandResult execute() { | ||
return new CommandResult(String.format(MESSAGE_COUNTED, addressBook.getSumPersons())); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
|
||
public class UtilsTest { | ||
|
||
|
||
@Test | ||
public void elementsAreUnique() throws Exception { | ||
// empty list | ||
|
@@ -36,11 +35,19 @@ public void elementsAreUnique() throws Exception { | |
assertNotUnique(null, "a", "b", null); | ||
} | ||
|
||
@Test | ||
public void isAnyNull() throws Exception { | ||
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. This commit shouldn't be part of this PR. In general, a PR should not contain unmerged code from other PRs. Try to limit each PR to one enhancement, which means the PR should be based on a branch that starts off from the master branch that is in sync with the upstream master branch |
||
assertFalse(Utils.isAnyNull()); | ||
assertFalse(Utils.isAnyNull(1, 2, 3)); | ||
assertTrue(Utils.isAnyNull(1, null, 2, 3)); | ||
} | ||
|
||
private void assertAreUnique(Object... objects) { | ||
assertTrue(Utils.elementsAreUnique(Arrays.asList(objects))); | ||
} | ||
|
||
private void assertNotUnique(Object... objects) { | ||
assertFalse(Utils.elementsAreUnique(Arrays.asList(objects))); | ||
} | ||
|
||
} |
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.
Good job updating the user doc