forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 4
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
19 changed files
with
416 additions
and
95 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
50 changes: 50 additions & 0 deletions
50
src/main/java/seedu/tarence/logic/commands/ConfirmNoCommand.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,50 @@ | ||
package seedu.tarence.logic.commands; | ||
|
||
import seedu.tarence.commons.core.Messages; | ||
import seedu.tarence.logic.commands.exceptions.CommandException; | ||
import seedu.tarence.model.Model; | ||
|
||
/** | ||
* Represent the user declining a previously stored command. | ||
* When executed, removes the stored command from the application. | ||
*/ | ||
public class ConfirmNoCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "n"; | ||
|
||
public static final String MESSAGE_CONFIRM_NO_SUCCESS = "Command cancelled"; | ||
|
||
public static final String[] COMMAND_SYNONYMS = {COMMAND_WORD, "no"}; | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
if (!model.hasPendingCommand()) { | ||
/* | ||
* While this is technically not an unknown command, from the user's point of view it is an illegal command. | ||
* We can only check for the validity of this command here and not in the ApplicationParser, to which the | ||
* model is not available. Hence, the exception is only thrown at this point. | ||
*/ | ||
throw new CommandException(Messages.MESSAGE_UNKNOWN_COMMAND); | ||
} | ||
model.getPendingCommand(); | ||
return new CommandResult(MESSAGE_CONFIRM_NO_SUCCESS); | ||
} | ||
|
||
/** | ||
* Returns true if user command matches command word or any defined synonyms, and false otherwise. | ||
* | ||
* @param userCommand command word from user. | ||
* @return whether user command matches specified command word or synonyms. | ||
*/ | ||
public static boolean isMatchingCommandWord(String userCommand) { | ||
for (String synonym : COMMAND_SYNONYMS) { | ||
if (synonym.equals(userCommand.toLowerCase())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} | ||
|
||
|
48 changes: 48 additions & 0 deletions
48
src/main/java/seedu/tarence/logic/commands/ConfirmYesCommand.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,48 @@ | ||
package seedu.tarence.logic.commands; | ||
|
||
import seedu.tarence.commons.core.Messages; | ||
import seedu.tarence.logic.commands.exceptions.CommandException; | ||
import seedu.tarence.model.Model; | ||
|
||
/** | ||
* Represent the user confirming a previously stored command. | ||
* When executed, retrieves and execute the stored command, and returns its {@code CommandResult}. | ||
*/ | ||
public class ConfirmYesCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "y"; | ||
|
||
public static final String[] COMMAND_SYNONYMS = {COMMAND_WORD, "yes", "confirm"}; | ||
|
||
// returns the result of executing the stored pending command | ||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
if (!model.hasPendingCommand()) { | ||
/* | ||
* While this is technically not an unknown command, from the user's point of view it is an illegal command. | ||
* We can only check for the validity of this command here and not in the ApplicationParser, to which the | ||
* model is not available. Hence, the exception is only thrown at this point. | ||
*/ | ||
throw new CommandException(Messages.MESSAGE_UNKNOWN_COMMAND); | ||
} | ||
return model.getPendingCommand().execute(model); | ||
} | ||
|
||
/** | ||
* Returns true if user command matches command word or any defined synonyms, and false otherwise. | ||
* | ||
* @param userCommand command word from user. | ||
* @return whether user command matches specified command word or synonyms. | ||
*/ | ||
public static boolean isMatchingCommandWord(String userCommand) { | ||
for (String synonym : COMMAND_SYNONYMS) { | ||
if (synonym.equals(userCommand.toLowerCase())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} | ||
|
||
|
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
26 changes: 26 additions & 0 deletions
26
src/main/java/seedu/tarence/logic/commands/DeleteModuleVerifiedCommand.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,26 @@ | ||
package seedu.tarence.logic.commands; | ||
|
||
import seedu.tarence.logic.commands.exceptions.CommandException; | ||
import seedu.tarence.model.Model; | ||
import seedu.tarence.model.module.Module; | ||
|
||
/** | ||
* Represents a followup to {@code DeletedModuleCommand} where the {@code Module} to be deleted has been verified as | ||
* a valid one in the application. | ||
*/ | ||
public class DeleteModuleVerifiedCommand extends Command { | ||
|
||
private Module moduleToDelete; | ||
|
||
DeleteModuleVerifiedCommand(Module moduleToDelete) { | ||
this.moduleToDelete = moduleToDelete; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
model.deleteTutorialsFromModule(moduleToDelete); | ||
model.deleteModule(moduleToDelete); | ||
return new CommandResult(String.format(DeleteModuleCommand.MESSAGE_DELETE_MODULE_SUCCESS, | ||
moduleToDelete)); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/seedu/tarence/logic/commands/DeleteTutorialVerifiedCommand.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,26 @@ | ||
package seedu.tarence.logic.commands; | ||
|
||
import seedu.tarence.logic.commands.exceptions.CommandException; | ||
import seedu.tarence.model.Model; | ||
import seedu.tarence.model.tutorial.Tutorial; | ||
|
||
/** | ||
* Represents a followup to {@code DeletedTutorialCommand} where the {@code Tutorial} to be deleted has been verified as | ||
* a valid one in the application. | ||
*/ | ||
public class DeleteTutorialVerifiedCommand extends Command { | ||
|
||
private Tutorial tutorialToDelete; | ||
|
||
DeleteTutorialVerifiedCommand(Tutorial tutorialToDelete) { | ||
this.tutorialToDelete = tutorialToDelete; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
model.deleteStudentsFromTutorial(tutorialToDelete); | ||
model.deleteTutorial(tutorialToDelete); | ||
return new CommandResult(String.format(DeleteTutorialCommand.MESSAGE_DELETE_TUTORIAL_SUCCESS, | ||
tutorialToDelete)); | ||
} | ||
} |
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.