diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 4abb17e3e..ecae0468c 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -156,6 +156,11 @@ Views all details of the 1st person in the results of the `find` command. Clears all entries from the address book. + Format: `clear` +== Prints a goodbye message : `goodbye` + +Prints message "goodbye world" +Format: `goodbye` + == Exiting the program : `exit` Exits the program. + diff --git a/src/seedu/addressbook/commands/GoodbyeCommand.java b/src/seedu/addressbook/commands/GoodbyeCommand.java new file mode 100644 index 000000000..f525e1ea1 --- /dev/null +++ b/src/seedu/addressbook/commands/GoodbyeCommand.java @@ -0,0 +1,20 @@ +package seedu.addressbook.commands; + + +/** + * print goodbye message. + */ +public class GoodbyeCommand extends Command { + + public static final String COMMAND_WORD = "goodbye"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + ": prints goodbye message.\n" + + "Example: " + COMMAND_WORD; + + @Override + public CommandResult execute() { + return new CommandResult( + "Goodbye World" + ); + } +} diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index 9be217d89..0735d5146 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -22,7 +22,8 @@ public CommandResult execute() { + "\n" + ViewCommand.MESSAGE_USAGE + "\n" + ViewAllCommand.MESSAGE_USAGE + "\n" + HelpCommand.MESSAGE_USAGE - + "\n" + ExitCommand.MESSAGE_USAGE + + "\n" + GoodbyeCommand.MESSAGE_USAGE + + "\n" + ExitCommand.MESSAGE_USAGE ); } } diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index abddb3f45..ef71b9c64 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -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.*; import seedu.addressbook.data.exception.IllegalValueException; /** @@ -73,6 +63,9 @@ public Command parseCommand(String userInput) { switch (commandWord) { + case GoodbyeCommand.COMMAND_WORD: + return new GoodbyeCommand(); + case AddCommand.COMMAND_WORD: return prepareAdd(arguments); diff --git a/test/expected.txt b/test/expected.txt index 56fe5fcac..d5f6170b2 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -27,6 +27,8 @@ || Example: viewall 1 || help: Shows program usage instructions. || Example: help +|| goodbye: prints goodbye message. +|| Example: goodbye || exit: Exits the program. || Example: exit || =================================================== diff --git a/test/java/seedu/addressbook/commands/AddCommandTest.java b/test/java/seedu/addressbook/commands/AddCommandTest.java index 461017710..543356bee 100644 --- a/test/java/seedu/addressbook/commands/AddCommandTest.java +++ b/test/java/seedu/addressbook/commands/AddCommandTest.java @@ -28,7 +28,7 @@ public class AddCommandTest { private static final List EMPTY_PERSON_LIST = Collections.emptyList(); private static final Set EMPTY_STRING_SET = Collections.emptySet(); - @Test + @org.junit.jupiter.api.Test public void addCommand_invalidName_throwsException() { final String[] invalidNames = { "", " ", "[]\\[;]" }; for (String name : invalidNames) { diff --git a/test/java/seedu/addressbook/parser/ParserTest.java b/test/java/seedu/addressbook/parser/ParserTest.java index 0dfc67cd2..ada850f26 100644 --- a/test/java/seedu/addressbook/parser/ParserTest.java +++ b/test/java/seedu/addressbook/parser/ParserTest.java @@ -12,6 +12,7 @@ import org.junit.Before; import org.junit.Test; +import seedu.addressbook.commands.GoodbyeCommand; import seedu.addressbook.commands.AddCommand; import seedu.addressbook.commands.ClearCommand; import seedu.addressbook.commands.Command; @@ -63,6 +64,12 @@ public void parse_unknownCommandWord_returnsHelp() { * Tests for 0-argument commands ======================================================================= */ + @Test + public void parse_goodbyeCommand_parsedCorrectly() { + final String input = "goodbye"; + parseAndAssertCommandType(input, GoodbyeCommand.class); + } + @Test public void parse_helpCommand_parsedCorrectly() { final String input = "help";