Skip to content
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][T09-3] Yow Ren Jie #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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. +
Expand Down
20 changes: 20 additions & 0 deletions src/seedu/addressbook/commands/GoodbyeCommand.java
Original file line number Diff line number Diff line change
@@ -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

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 (in this case your enhancement functionality) should have java doc format header comments.

public CommandResult execute() {
return new CommandResult(
"Goodbye World"
);
}
}
3 changes: 2 additions & 1 deletion src/seedu/addressbook/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary indentation. Reduces code readability.

+ "\n" + ExitCommand.MESSAGE_USAGE
);
}
}
15 changes: 4 additions & 11 deletions src/seedu/addressbook/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imported classes should always be listed explicitly. E.g. java.util.List and not java.util.*, which does not follow NUS Java coding standards.

import seedu.addressbook.data.exception.IllegalValueException;

/**
Expand Down Expand Up @@ -73,6 +63,9 @@ public Command parseCommand(String userInput) {

switch (commandWord) {

case GoodbyeCommand.COMMAND_WORD:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary indentation here.

return new GoodbyeCommand();

case AddCommand.COMMAND_WORD:
return prepareAdd(arguments);

Expand Down
2 changes: 2 additions & 0 deletions test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
|| ===================================================
Expand Down
2 changes: 1 addition & 1 deletion test/java/seedu/addressbook/commands/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AddCommandTest {
private static final List<ReadOnlyPerson> EMPTY_PERSON_LIST = Collections.emptyList();
private static final Set<String> EMPTY_STRING_SET = Collections.emptySet();

@Test
@org.junit.jupiter.api.Test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change do?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gautamrajulu how do you declare that a method is a test method?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ren jie why do you need a new junit framework for this enhancement?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arhjaye why do you need another junit test framework for your enhancement?

public void addCommand_invalidName_throwsException() {

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.

final String[] invalidNames = { "", " ", "[]\\[;]" };
for (String name : invalidNames) {
Expand Down
7 changes: 7 additions & 0 deletions test/java/seedu/addressbook/parser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down