-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from SoilingRogue/branch-SwitchParser
Order command implementation
- Loading branch information
Showing
4 changed files
with
71 additions
and
7 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
40 changes: 38 additions & 2 deletions
40
src/main/java/seedu/deliverymans/logic/commands/customer/OrderCommand.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 |
---|---|---|
@@ -1,18 +1,54 @@ | ||
package seedu.deliverymans.logic.commands.customer; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.deliverymans.logic.parser.CliSyntax.PREFIX_CUSTOMER; | ||
import static seedu.deliverymans.logic.parser.CliSyntax.PREFIX_DELIVERYMAN; | ||
import static seedu.deliverymans.logic.parser.CliSyntax.PREFIX_ORDER; | ||
import static seedu.deliverymans.logic.parser.CliSyntax.PREFIX_RESTAURANT; | ||
|
||
import seedu.deliverymans.logic.commands.Command; | ||
import seedu.deliverymans.logic.commands.CommandResult; | ||
import seedu.deliverymans.logic.commands.exceptions.CommandException; | ||
import seedu.deliverymans.model.Model; | ||
import seedu.deliverymans.model.order.Order; | ||
|
||
/** | ||
* (to be added) | ||
* Order command | ||
*/ | ||
public class OrderCommand extends Command { | ||
public static final String COMMAND_WORD = "order"; | ||
|
||
public static final String MESSAGE_ADD_SUCCESS = "Added order: %1$s"; | ||
|
||
public static final String MESSAGE_ADD_ORDER_USAGE = COMMAND_WORD | ||
+ ": Adds an order to the manager. " | ||
+ "Parameters: " | ||
+ PREFIX_ORDER + "ORDER " | ||
+ "[" + PREFIX_CUSTOMER + "CUSTOMER]\n" | ||
+ "[" + PREFIX_RESTAURANT + "RESTAURANT]\n" | ||
+ "[" + PREFIX_DELIVERYMAN + "DELIVERYMAN]\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_CUSTOMER + "Sam " | ||
+ PREFIX_RESTAURANT + "KFC " | ||
+ PREFIX_DELIVERYMAN + "Deliveryman #1337"; | ||
|
||
private final Order toAdd; | ||
|
||
public OrderCommand(Order toAdd) { | ||
requireNonNull(toAdd); | ||
this.toAdd = toAdd; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
return null; | ||
model.addOrder(toAdd); | ||
return new CommandResult(String.format(MESSAGE_ADD_SUCCESS, toAdd)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof OrderCommand // instanceof handles nulls | ||
&& toAdd.equals(((OrderCommand) other).toAdd)); | ||
} | ||
} |
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