Skip to content
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
4 changes: 4 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ What's different from AddressBook-Level1:
* Support for marking a contact detail as 'private' (`pa/`) (`pe/`) (`pp/`)
* View details of a person (`view` : shows non-private details), (`viewall` : shows all details)

== Enhancements added by Samuel

feedbackToUser of the CommandResult class is now encapsulated(??)

== Viewing help : `help`

Format: `help`
Expand Down
5 changes: 4 additions & 1 deletion src/seedu/addressbook/commands/CommandResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class CommandResult {

/** The feedback message to be shown to the user. Contains a description of the execution result */
public final String feedbackToUser;
private final String feedbackToUser;

/** The list of persons that was produced by the command */
private final List<? extends ReadOnlyPerson> relevantPersons;
Expand All @@ -33,4 +33,7 @@ public Optional<List<? extends ReadOnlyPerson>> getRelevantPersons() {
return Optional.ofNullable(relevantPersons);
}

public String getFeedbackToUser() {

Copy link
Copy Markdown

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 feedbackToUser;
}
}
2 changes: 1 addition & 1 deletion src/seedu/addressbook/ui/TextUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void showResultToUser(CommandResult result) {
if (resultPersons.isPresent()) {
showPersonListView(resultPersons.get());
}
showToUser(result.feedbackToUser, DIVIDER);
showToUser(result.getFeedbackToUser(), DIVIDER);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/java/seedu/addressbook/commands/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void addCommand_emptyAddressBook_addressBookContainsPerson() {
assertTrue(people.contains(p));
assertEquals(1, people.immutableListView().size());
assertFalse(result.getRelevantPersons().isPresent());
assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, p), result.feedbackToUser);
assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, p), result.getFeedbackToUser());
}

@Test
Expand All @@ -139,7 +139,7 @@ public void addCommand_addressBookAlreadyContainsPerson_addressBookUnmodified()
CommandResult result = command.execute();

assertFalse(result.getRelevantPersons().isPresent());
assertEquals(AddCommand.MESSAGE_DUPLICATE_PERSON, result.feedbackToUser);
assertEquals(AddCommand.MESSAGE_DUPLICATE_PERSON, result.getFeedbackToUser());
UniquePersonList people = book.getAllPersons();
assertTrue(people.contains(p));
assertEquals(1, people.immutableListView().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void assertCommandBehaviour(DeleteCommand deleteCommand, String expected

CommandResult result = deleteCommand.execute();

assertEquals(expectedMessage, result.feedbackToUser);
assertEquals(expectedMessage, result.getFeedbackToUser());
assertEquals(expectedAddressBook.getAllPersons(), actualAddressBook.getAllPersons());
}

Expand Down
2 changes: 1 addition & 1 deletion test/java/seedu/addressbook/commands/FindCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void assertFindCommandBehavior(String[] keywords, List<ReadOnlyPerson> e
FindCommand command = createFindCommand(keywords);
CommandResult result = command.execute();

assertEquals(Command.getMessageForPersonListShownSummary(expectedPersonList), result.feedbackToUser);
assertEquals(Command.getMessageForPersonListShownSummary(expectedPersonList), result.getFeedbackToUser());
}

private FindCommand createFindCommand(String[] keywords) {
Expand Down
2 changes: 1 addition & 1 deletion test/java/seedu/addressbook/commands/ViewCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private static void assertViewBehavior(Command viewCommand, AddressBook addressB
CommandResult result = viewCommand.execute();

// feedback message is as expected and there are no relevant persons returned.
assertEquals(expectedMessage, result.feedbackToUser);
assertEquals(expectedMessage, result.getFeedbackToUser());
assertEquals(Optional.empty(), result.getRelevantPersons());

// addressbook was not modified.
Expand Down