-
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][F10-2]Liu Xiaohang #446
base: master
Are you sure you want to change the base?
Conversation
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.
Don't add code that you haven't implement. Create an issue instead.
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.
Commit message isn't a sentence. Don't end with a period.
@@ -81,6 +81,17 @@ public UniquePersonList(UniquePersonList source) { | |||
return Collections.unmodifiableList(internalList); | |||
} | |||
|
|||
/** | |||
* Returns an unmodifiable java List view with elements cast as immutable {@link ReadOnlyPerson}s. |
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.
@@ -23,6 +23,7 @@ public CommandResult execute() { | |||
+ "\n" + ViewAllCommand.MESSAGE_USAGE | |||
+ "\n" + HelpCommand.MESSAGE_USAGE | |||
+ "\n" + ExitCommand.MESSAGE_USAGE | |||
+ "\n" + SortCommand.MESSAGE_USAGE |
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.
/nit: Why is sort at the end?
public static final String COMMAND_WORD = "sort"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": sort people in the address book.\n" | ||
+ "Example: " + COMMAND_WORD; |
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.
Inconsistant '+' alignment.
import seedu.addressbook.data.person.UniquePersonList; | ||
import seedu.addressbook.data.tag.Tag; | ||
|
||
public class SortCommand extends Command{ |
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.
/nit space before {
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 on attempting the LO. You seem to have difficulty implementing the tests for the new sort command. Do approach me if you need any help :)
@@ -36,6 +36,16 @@ public static String getMessageForPersonListShownSummary(List<? extends ReadOnly | |||
return String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, personsDisplayed.size()); | |||
} | |||
|
|||
/** | |||
* Constructs a feedback message to summarise an operation that displayed a list of sorted persons. |
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.
summarize (use American spelling), displays
* @param personsDisplayed used to generate summary | ||
* @return summary message for persons displayed | ||
*/ | ||
public static String getMessageForPersonSortShownSummary(List<? extends ReadOnlyPerson> personsDisplayed) { |
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.
Hmm... method name is not that intuitive
* Any changes to the internal list/elements are immediately visible in the returned list. | ||
*/ | ||
public List<ReadOnlyPerson> sortedListView() { | ||
//internalList.sort(); <--how to make this line work instead of using Collections.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.
https://docs.oracle.com/javase/8/docs/api/java/util/List.html
You have to pass in a comparator in this case. However, we usually just use Collections.sort/ Arrays.sort
case HelpCommand.COMMAND_WORD: // Fallthrough | ||
|
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.
Avoid adding unnecessary new line
Add sort command. Use the idea from the instructions on the CS2103/T website "Add a SortCommand class but make it simply a copy of the the existing ListCommand. Direct the sort command to the new SortCommand."