diff --git a/src/main/java/seedu/address/logic/commands/ExitCommand.java b/src/main/java/seedu/address/logic/commands/ExitCommand.java index 54a3b117239..4abf6a86fa8 100644 --- a/src/main/java/seedu/address/logic/commands/ExitCommand.java +++ b/src/main/java/seedu/address/logic/commands/ExitCommand.java @@ -17,4 +17,13 @@ public CommandResult execute(Model model, EventManager eventManager) { return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true); } + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + return other instanceof ExitCommand; + } + } diff --git a/src/main/java/seedu/address/logic/commands/event/commands/ViewEventCommand.java b/src/main/java/seedu/address/logic/commands/event/commands/ViewEventCommand.java index 953bf37bff6..cc336d3e673 100644 --- a/src/main/java/seedu/address/logic/commands/event/commands/ViewEventCommand.java +++ b/src/main/java/seedu/address/logic/commands/event/commands/ViewEventCommand.java @@ -47,6 +47,7 @@ public CommandResult execute(Model model, EventManager eventManager) throws Comm Event eventToView = events.get(targetIndex.getZeroBased()); model.updateFilteredPersonList(eventManager.getPersonInEventPredicate(eventToView)); + return new CommandResult(String.format(MESSAGE_SUCCESS, eventToView.getName())); } diff --git a/src/main/java/seedu/address/logic/commands/searchmode/ExitSearchModeCommand.java b/src/main/java/seedu/address/logic/commands/searchmode/ExitSearchModeCommand.java index 2272595f350..efd8314632d 100644 --- a/src/main/java/seedu/address/logic/commands/searchmode/ExitSearchModeCommand.java +++ b/src/main/java/seedu/address/logic/commands/searchmode/ExitSearchModeCommand.java @@ -12,7 +12,7 @@ * Exits search mode. */ public class ExitSearchModeCommand extends Command { - public static final String COMMAND_WORD = "exitsearchmode"; + public static final String COMMAND_WORD = "exitsearch"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Exits search mode.\n" + "Example: " + COMMAND_WORD; diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 82890a6e2c4..27b653c0913 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -151,8 +151,11 @@ public Command parseSearchCommand(String userInput) throws ParseException { return new ExitSearchModeCommand(); case SearchModeSearchCommand.COMMAND_WORD: return new SearchModeSearchCommandParser().parse(arguments); + case ExitCommand.COMMAND_WORD: + return new ExitCommand(); default: - throw new ParseException(MESSAGE_UNKNOWN_COMMAND); + throw new ParseException( + MESSAGE_UNKNOWN_COMMAND + "\nYou are in searchmode.\nUse only search, exitsearch or exit"); } } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index ede190c7c03..066f03d7dd3 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -210,5 +210,4 @@ public boolean equals(Object other) { public ObservableList getAllPersons() { return addressBook.getPersonList(); } - } diff --git a/src/main/java/seedu/address/model/event/Event.java b/src/main/java/seedu/address/model/event/Event.java index 250d6f4680a..f42bffa5c25 100644 --- a/src/main/java/seedu/address/model/event/Event.java +++ b/src/main/java/seedu/address/model/event/Event.java @@ -13,9 +13,6 @@ import seedu.address.model.role.exceptions.InvalidRoleException; - - - /** * Represents an Event in the address book. */ diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index ea3e98600b9..567a178960e 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -72,16 +72,16 @@ public static Event[] getSampleEvents() { return new Event[] { new Event("NUS Student Life Fair 2024", - getPersonSet(samplePersons[0], samplePersons[1]), + getPersonSet(samplePersons[0]), + getPersonSet(samplePersons[1]), getPersonSet(samplePersons[2]), - getPersonSet(samplePersons[3]), - getPersonSet(samplePersons[4]) + getPersonSet(samplePersons[1]) ), new Event("NUS Open House 2024", - getPersonSet(samplePersons[1]), - getPersonSet(samplePersons[0], samplePersons[2]), + getPersonSet(samplePersons[3], samplePersons[4]), getPersonSet(samplePersons[3]), - getPersonSet(samplePersons[4], samplePersons[5]) + getPersonSet(samplePersons[5]), + getPersonSet(samplePersons[1]) ) }; } diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index e63e5d6915e..78106dce1a7 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -139,12 +139,6 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { */ void fillInnerParts() { updateUiBasedOnSearchMode(logic.getSearchMode().get()); - // personListPanel = new PersonListPanel(logic.getFilteredPersonList()); - // personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); - // if (logic.getSearchMode()) { - // allPersonListPanel = new PersonListPanel(logic.getAllPersons()); - // personListPanelPlaceholder.getChildren().add(allPersonListPanel.getRoot()); - // } eventListPanel = new EventListPanel(logic.getFilteredEventList()); eventListPanelPlaceholder.getChildren().add(eventListPanel.getRoot()); diff --git a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java index 9533c473875..a5569bb7733 100644 --- a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java @@ -1,5 +1,7 @@ package seedu.address.logic.commands; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.logic.commands.ExitCommand.MESSAGE_EXIT_ACKNOWLEDGEMENT; @@ -17,4 +19,31 @@ public void execute_exit_success() { CommandResult expectedCommandResult = new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true); assertCommandSuccess(new ExitCommand(), model, expectedCommandResult, expectedModel); } + + @Test + public void equals_sameObject_returnsTrue() { + ExitCommand exitCommand = new ExitCommand(); + assertTrue(exitCommand.equals(exitCommand)); + } + + @Test + public void equals_differentInstanceSameType_returnsTrue() { + ExitCommand exitCommand1 = new ExitCommand(); + ExitCommand exitCommand2 = new ExitCommand(); + assertTrue(exitCommand1.equals(exitCommand2)); + } + + @Test + public void equals_differentType_returnsFalse() { + ExitCommand exitCommand = new ExitCommand(); + Object notExitCommand = new Object(); + assertFalse(exitCommand.equals(notExitCommand)); + } + + @Test + public void equals_null_returnsFalse() { + ExitCommand exitCommand = new ExitCommand(); + assertFalse(exitCommand.equals(null)); + } + } diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index a8a03285a67..56c2413fa88 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -159,6 +159,12 @@ public void parseSearchCommand_exitSearchModeCommand() throws ParseException { assertEquals(expected, new AddressBookParser() .parseSearchCommand(ExitSearchModeCommand.COMMAND_WORD)); } + @Test + public void parseSearchCommand_exitCommand() throws ParseException { + Command expected = new ExitCommand(); + assertEquals(expected, new AddressBookParser() + .parseSearchCommand(ExitCommand.COMMAND_WORD)); + } @Test public void parseSearchCommand_unrecognisedInput_throwsParseException() {