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

[W7][T11-2] Teo Xuan Wei #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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. +
Expand Down
2 changes: 1 addition & 1 deletion src/seedu/addressbook/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Main entry point to the application.
*/
public class Main extends Application implements Stoppable{

// test commit

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.

/** Version info of the program. */
public static final String VERSION = "AddressBook Level 3 - Version 1.0";

Expand Down
1 change: 1 addition & 0 deletions src/seedu/addressbook/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class HelpCommand extends Command {
+ "\n" + DeleteCommand.MESSAGE_USAGE
+ "\n" + ClearCommand.MESSAGE_USAGE
+ "\n" + FindCommand.MESSAGE_USAGE
+ "\n" + LengthCommand.MESSAGE_USAGE
+ "\n" + ListCommand.MESSAGE_USAGE
+ "\n" + ViewCommand.MESSAGE_USAGE
+ "\n" + ViewAllCommand.MESSAGE_USAGE
Expand Down
13 changes: 13 additions & 0 deletions src/seedu/addressbook/commands/LengthCommand.java
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

Choose a reason for hiding this comment

The 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());
}
}
6 changes: 5 additions & 1 deletion src/seedu/addressbook/data/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public void clear() {
allPersons.clear();
}

public int size() {

Choose a reason for hiding this comment

The 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.
*/
Expand All @@ -83,4 +87,4 @@ public boolean equals(Object other) {
public int hashCode() {
return allPersons.hashCode();
}
}
}
8 changes: 8 additions & 0 deletions src/seedu/addressbook/data/person/UniquePersonList.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ public void clear() {
internalList.clear();
}

/**
* New method to get size of address book :D

Choose a reason for hiding this comment

The 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();
Expand Down
3 changes: 3 additions & 0 deletions src/seedu/addressbook/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public Command parseCommand(String userInput) {
case FindCommand.COMMAND_WORD:
return prepareFind(arguments);

case LengthCommand.COMMAND_WORD:
return new LengthCommand();

case ListCommand.COMMAND_WORD:
return new ListCommand();

Expand Down