-
Notifications
You must be signed in to change notification settings - Fork 113
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][W17-1] Lee Wei Kang #144
base: master
Are you sure you want to change the base?
Changes from 3 commits
10b08c9
6f091de
b84aed4
8c6b885
5c4a43c
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,23 @@ | ||
package seedu.addressbook.commands; | ||
|
||
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class SortCommand extends Command{ | ||
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 look out for the missing whitespace between |
||
public static final String COMMAND_WORD = "sort"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Displays all persons in the address book as a list with index numbers sorted by their name.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
|
||
@Override | ||
public CommandResult execute() { | ||
List<ReadOnlyPerson> allPersons = addressBook.getAllPersons().immutableListView(); | ||
List<ReadOnlyPerson> newList = new ArrayList<>(allPersons); | ||
Collections.sort(newList); | ||
return new CommandResult(getMessageForPersonListShownSummary(newList), newList); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,17 +11,7 @@ | |
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import seedu.addressbook.commands.AddCommand; | ||
import seedu.addressbook.commands.ClearCommand; | ||
import seedu.addressbook.commands.Command; | ||
import seedu.addressbook.commands.DeleteCommand; | ||
import seedu.addressbook.commands.ExitCommand; | ||
import seedu.addressbook.commands.FindCommand; | ||
import seedu.addressbook.commands.HelpCommand; | ||
import seedu.addressbook.commands.IncorrectCommand; | ||
import seedu.addressbook.commands.ListCommand; | ||
import seedu.addressbook.commands.ViewAllCommand; | ||
import seedu.addressbook.commands.ViewCommand; | ||
import seedu.addressbook.commands.*; | ||
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. Suggest switching back to importing commands one by one as mentioned in class. 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. Thanks for the reminder! 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. Since you've added a new command, it would be good if you could add it in the Help Command's guide as instructions for new users 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. Yes definitely! Thank you for your suggestion! (: |
||
import seedu.addressbook.data.exception.IllegalValueException; | ||
|
||
/** | ||
|
@@ -88,6 +78,9 @@ public Command parseCommand(String userInput) { | |
case ListCommand.COMMAND_WORD: | ||
return new ListCommand(); | ||
|
||
case SortCommand.COMMAND_WORD: | ||
return new SortCommand(); | ||
|
||
case ViewCommand.COMMAND_WORD: | ||
return prepareView(arguments); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,27 +112,45 @@ | |
|| | ||
|| 3 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: add Dickson Ee p/444444 pe/[email protected] a/444, delta street t/friends] | ||
|| New person added: Dickson Ee Phone: 444444 Email: (private) [email protected] Address: 444, delta street Tags: [friends] | ||
|| Enter command: || [Command entered: add Esther Potato p/555555 e/[email protected] pa/555, epsilon street t/tubers t/starchy] | ||
|| New person added: Esther Potato Phone: 555555 Email: [email protected] Address: (private) 555, epsilon street Tags: [tubers][starchy] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: list] | ||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: | ||
|| 2. Betsy Choo Tags: [secretive] | ||
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends] | ||
|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| 4. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy] | ||
|| | ||
|| 4 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: add Esther Potato p/555555 e/[email protected] pa/555, epsilon street t/tubers t/starchy] | ||
|| New person added: Esther Potato Phone: 555555 Email: [email protected] Address: (private) 555, epsilon street Tags: [tubers][starchy] | ||
|| Enter command: || [Command entered: add Dickson Ee p/444444 pe/[email protected] a/444, delta street t/friends] | ||
|| New person added: Dickson Ee Phone: 444444 Email: (private) [email protected] Address: 444, delta street Tags: [friends] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: list] | ||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: | ||
|| 2. Betsy Choo Tags: [secretive] | ||
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends] | ||
|| 4. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy] | ||
|| 5. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| | ||
|| 5 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: sort] | ||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: | ||
|| 2. Betsy Choo Tags: [secretive] | ||
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends] | ||
|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| 5. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy] | ||
|| | ||
|| | ||
|| 5 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: list] | ||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: | ||
|| 2. Betsy Choo Tags: [secretive] | ||
|| 3. Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends] | ||
|| 4. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy] | ||
|| 5. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| | ||
|| 5 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: add Esther Potato p/555555 e/[email protected] pa/555, epsilon street t/tubers t/starchy] | ||
|
@@ -183,19 +201,19 @@ | |
|| Enter command: || [Command entered: view 3] | ||
|| Viewing person: Charlie Dickson Email: [email protected] Address: 333, gamma street Tags: [school][friends] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: view 4] | ||
|| Enter command: || [Command entered: view 5] | ||
|| Viewing person: Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: view 5] | ||
|| Enter command: || [Command entered: view 4] | ||
|| Viewing person: Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: viewall 3] | ||
|| Viewing person: Charlie Dickson Phone: (private) 333333 Email: [email protected] Address: 333, gamma street Tags: [school][friends] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: viewall 4] | ||
|| Enter command: || [Command entered: viewall 5] | ||
|| Viewing person: Dickson Ee Phone: 444444 Email: (private) [email protected] Address: 444, delta street Tags: [friends] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: viewall 5] | ||
|| Enter command: || [Command entered: viewall 4] | ||
|| Viewing person: Esther Potato Phone: 555555 Email: [email protected] Address: (private) 555, epsilon street Tags: [tubers][starchy] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: find] | ||
|
@@ -266,12 +284,12 @@ | |
|| Enter command: || [Command entered: list] | ||
|| 1. Adam Brown Phone: 111111 Email: [email protected] Address: 111, alpha street Tags: | ||
|| 2. Betsy Choo Tags: [secretive] | ||
|| 3. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| 4. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy] | ||
|| 3. Esther Potato Phone: 555555 Email: [email protected] Tags: [tubers][starchy] | ||
|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] | ||
|| | ||
|| 4 persons listed! | ||
|| =================================================== | ||
|| Enter command: || [Command entered: delete 4] | ||
|| Enter command: || [Command entered: delete 3] | ||
|| Deleted Person: Esther Potato Phone: 555555 Email: [email protected] Address: (private) 555, epsilon street Tags: [tubers][starchy] | ||
|| =================================================== | ||
|| Enter command: || [Command entered: list] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,11 @@ | |
list | ||
add Charlie Dickson pp/333333 e/[email protected] a/333, gamma street t/friends t/school | ||
list | ||
add Esther Potato p/555555 e/[email protected] pa/555, epsilon street t/tubers t/starchy | ||
list | ||
add Dickson Ee p/444444 pe/[email protected] a/444, delta street t/friends | ||
list | ||
add Esther Potato p/555555 e/[email protected] pa/555, epsilon street t/tubers t/starchy | ||
sort | ||
list | ||
|
||
# should not allow adding duplicate persons | ||
|
@@ -78,13 +80,13 @@ | |
|
||
# should show only non private details for view | ||
view 3 | ||
view 4 | ||
view 5 | ||
view 4 | ||
|
||
# should show all details even private for viewall | ||
viewall 3 | ||
viewall 4 | ||
viewall 5 | ||
viewall 4 | ||
|
||
########################################################## | ||
# test find persons command | ||
|
@@ -133,7 +135,7 @@ | |
list | ||
|
||
# deletes correct person | ||
delete 4 | ||
delete 3 | ||
list | ||
|
||
# listing indexes get updated on next request | ||
|
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.
I think perhaps the format is wrong? For a sort command, the format should be: 'sort'?
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.
Yes thanks for pointing that out!