-
Notifications
You must be signed in to change notification settings - Fork 36
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
[W7][T11-2] Teo Xuan Wei #46
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -49,6 +49,11 @@ Examples: | |
* `add John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01` | ||
* `add Betsy Crowe pp/1234567 e/[email protected] pa/Newgate Prison t/criminal t/friend` | ||
|
||
== Finding out the current length of the address book : `length` | ||
|
||
Shows the number of entries in the address book. + | ||
Format: `length` | ||
|
||
== Listing all persons : `list` | ||
|
||
Shows a list of all persons in the address book. + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package seedu.addressbook.commands; | ||
|
||
public class LengthCommand extends Command { | ||
public static final String COMMAND_WORD = "length"; | ||
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Returns the current length of the address book at the point of query.\n\t" | ||
+ "Example: " + COMMAND_WORD; | ||
public static final String MESSAGE_SUCCESS = "Length of the address book is: "; | ||
|
||
@Override | ||
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. Missing header comment. All non-trivial methods should have java doc format header comments. |
||
public CommandResult execute() { | ||
return new CommandResult(MESSAGE_SUCCESS + addressBook.size()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,10 @@ public void clear() { | |
allPersons.clear(); | ||
} | ||
|
||
public int 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. Missing header comment. All non-trivial methods should have java doc format header comments. |
||
return allPersons.size(); | ||
} | ||
|
||
/** | ||
* Defensively copied UniquePersonList of all persons in the address book at the time of the call. | ||
*/ | ||
|
@@ -83,4 +87,4 @@ public boolean equals(Object other) { | |
public int hashCode() { | ||
return allPersons.hashCode(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,14 @@ public void clear() { | |
internalList.clear(); | ||
} | ||
|
||
/** | ||
* New method to get size of address book :D | ||
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. Do note that your header comment should begin with a verb - e.g. Gets size of address book. This is the standard java coding convention that we are following. |
||
* Returns the number of persons in the list. | ||
*/ | ||
public int size() { | ||
return internalList.size(); | ||
} | ||
|
||
@Override | ||
public Iterator<Person> iterator() { | ||
return internalList.iterator(); | ||
|
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.
Unnecessary comments should be removed.