From c274114ac0cb355dbb0af35af2434861f10005b2 Mon Sep 17 00:00:00 2001 From: Yefenyi Date: Mon, 24 Apr 2017 21:48:55 +0800 Subject: [PATCH] T3A1 --- src/seedu/addressbook/commands/CommandResult.java | 5 ++++- src/seedu/addressbook/ui/TextUi.java | 2 +- test/java/seedu/addressbook/commands/AddCommandTest.java | 4 ++-- test/java/seedu/addressbook/commands/DeleteCommandTest.java | 2 +- test/java/seedu/addressbook/commands/FindCommandTest.java | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/seedu/addressbook/commands/CommandResult.java b/src/seedu/addressbook/commands/CommandResult.java index cf4e72585..2a4ce0372 100644 --- a/src/seedu/addressbook/commands/CommandResult.java +++ b/src/seedu/addressbook/commands/CommandResult.java @@ -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 relevantPersons; @@ -26,6 +26,9 @@ public CommandResult(String feedbackToUser, List relev this.relevantPersons = relevantPersons; } + public String getFeedback(){ + return this.feedbackToUser; + } /** * Returns list of persons relevant to the command command result, if any. */ diff --git a/src/seedu/addressbook/ui/TextUi.java b/src/seedu/addressbook/ui/TextUi.java index 94a9e6aa4..d8bdd6bc5 100644 --- a/src/seedu/addressbook/ui/TextUi.java +++ b/src/seedu/addressbook/ui/TextUi.java @@ -125,7 +125,7 @@ public void showResultToUser(CommandResult result) { if (resultPersons.isPresent()) { showPersonListView(resultPersons.get()); } - showToUser(result.feedbackToUser, DIVIDER); + showToUser(result.getFeedback(), DIVIDER); } /** diff --git a/test/java/seedu/addressbook/commands/AddCommandTest.java b/test/java/seedu/addressbook/commands/AddCommandTest.java index fd870a62e..e3f44bdba 100644 --- a/test/java/seedu/addressbook/commands/AddCommandTest.java +++ b/test/java/seedu/addressbook/commands/AddCommandTest.java @@ -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.getFeedback()); } @Test @@ -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.getFeedback()); UniquePersonList people = book.getAllPersons(); assertTrue(people.contains(p)); assertEquals(1, people.immutableListView().size()); diff --git a/test/java/seedu/addressbook/commands/DeleteCommandTest.java b/test/java/seedu/addressbook/commands/DeleteCommandTest.java index 0e5ab80d9..66f44400a 100644 --- a/test/java/seedu/addressbook/commands/DeleteCommandTest.java +++ b/test/java/seedu/addressbook/commands/DeleteCommandTest.java @@ -109,7 +109,7 @@ private void assertCommandBehaviour(DeleteCommand deleteCommand, String expected CommandResult result = deleteCommand.execute(); - assertEquals(expectedMessage, result.feedbackToUser); + assertEquals(expectedMessage, result.getFeedback()); assertEquals(expectedAddressBook.getAllPersons(), actualAddressBook.getAllPersons()); } diff --git a/test/java/seedu/addressbook/commands/FindCommandTest.java b/test/java/seedu/addressbook/commands/FindCommandTest.java index f21b1e8e7..48b6f7544 100644 --- a/test/java/seedu/addressbook/commands/FindCommandTest.java +++ b/test/java/seedu/addressbook/commands/FindCommandTest.java @@ -50,7 +50,7 @@ private void assertFindCommandBehavior(String[] keywords, List e FindCommand command = createFindCommand(keywords); CommandResult result = command.execute(); - assertEquals(Command.getMessageForPersonListShownSummary(expectedPersonList), result.feedbackToUser); + assertEquals(Command.getMessageForPersonListShownSummary(expectedPersonList), result.getFeedback()); } private FindCommand createFindCommand(String[] keywords) {