forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
767 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/seedu/billboard/logic/commands/HistoryCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package seedu.billboard.logic.commands; | ||
|
||
import seedu.billboard.model.Model; | ||
import seedu.billboard.model.history.CommandHistory; | ||
|
||
/** | ||
* Displays all history command. | ||
*/ | ||
public class HistoryCommand extends Command { | ||
public static final String COMMAND_WORD = "history"; | ||
public static final String MESSAGE_EMPTY_HISTORY = "There is no command history."; | ||
|
||
|
||
/** | ||
* Executes the command and returns the result message. | ||
* | ||
* @param model {@code Model} which the command should operate on. | ||
* @return feedback message of the operation result for display | ||
*/ | ||
@Override | ||
public CommandResult execute(Model model) { | ||
if (!CommandHistory.hasCommand()) { | ||
return new CommandResult(MESSAGE_EMPTY_HISTORY); | ||
} | ||
|
||
CommandResult cmdResult = new CommandResult(CommandHistory.getCmdHistory()); | ||
return cmdResult; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/seedu/billboard/logic/commands/RedoCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package seedu.billboard.logic.commands; | ||
|
||
import seedu.billboard.logic.commands.exceptions.CommandException; | ||
import seedu.billboard.model.Model; | ||
import seedu.billboard.model.versionedbillboard.VersionedBillboard; | ||
|
||
/** | ||
* Undo the previous edit action. | ||
*/ | ||
public class RedoCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "redo"; | ||
public static final String EMPTY_UNDO_LIST = "There is no command to be redone."; | ||
public static final String MESSAGE_REDO_SUCCESS = COMMAND_WORD + ": %s"; | ||
|
||
/** | ||
* Executes the command and returns the result message. | ||
* | ||
* @param model {@code Model} which the command should operate on. | ||
* @return feedback message of the operation result for display | ||
* @throws CommandException If an error occurs during command execution. | ||
*/ | ||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
if (!VersionedBillboard.isRedoable()) { | ||
throw new CommandException(EMPTY_UNDO_LIST); | ||
} | ||
|
||
String redoCmd = VersionedBillboard.getRedoCmd(); | ||
Model undoModel = VersionedBillboard.redo(); | ||
model.setModel(undoModel); | ||
CommandResult cmdResult = new CommandResult(String.format(MESSAGE_REDO_SUCCESS, redoCmd)); | ||
return cmdResult; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/seedu/billboard/logic/commands/UndoCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package seedu.billboard.logic.commands; | ||
|
||
import seedu.billboard.logic.commands.exceptions.CommandException; | ||
import seedu.billboard.model.Model; | ||
import seedu.billboard.model.versionedbillboard.VersionedBillboard; | ||
|
||
/** | ||
* Undo the previous edit action. | ||
*/ | ||
public class UndoCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "undo"; | ||
public static final String EMPTY_UNDO_LIST = "There is no command to be undone."; | ||
public static final String MESSAGE_UNDO_SUCCESS = COMMAND_WORD + ": %s"; | ||
|
||
/** | ||
* Executes the command and returns the result message. | ||
* | ||
* @param model {@code Model} which the command should operate on. | ||
* @return feedback message of the operation result for display | ||
* @throws CommandException If an error occurs during command execution. | ||
*/ | ||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
if (!VersionedBillboard.isUndoable()) { | ||
throw new CommandException(EMPTY_UNDO_LIST); | ||
} | ||
|
||
Model undoModel = VersionedBillboard.undo(); | ||
String undoCmd = VersionedBillboard.getUndoCmd(); | ||
model.setModel(undoModel); | ||
CommandResult cmdResult = new CommandResult(String.format(MESSAGE_UNDO_SUCCESS, undoCmd)); | ||
return cmdResult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.