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
25 changed files
with
517 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
|
||
/** | ||
* Navigates to the specified tab. | ||
*/ | ||
public class GoCommand extends Command { | ||
|
||
public static final String DEFAULT_TAB = "default"; | ||
public static final String HOME_TAB = "home"; | ||
public static final String HISTORY_TAB = "history"; | ||
|
||
public static final String COMMAND_WORD = "go"; | ||
|
||
public static final String MESSAGE_GO_SUCCESS = "Navigated to %s tab!"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Navigates to the specified tab bar " | ||
+ "the specified keywords (case-sensitive) " | ||
+ "\n" | ||
+ "Parameters: TAB_NAME" | ||
+ "\n" | ||
+ "Example: " + COMMAND_WORD + " history"; | ||
|
||
private String tabType; | ||
|
||
public GoCommand(String tabType) { | ||
this.tabType = tabType; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
return new CommandResult(String.format(MESSAGE_GO_SUCCESS, tabType), false, false, tabType); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/seedu/address/logic/commands/ViewCustomerTaskCommand.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.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.List; | ||
|
||
import seedu.address.commons.core.Messages; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Customer; | ||
|
||
/** | ||
* List the completed delivery task of a particular customer. | ||
*/ | ||
public class ViewCustomerTaskCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "viewC"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Views the delivered tasks of the specified customer " | ||
+ "and displays them as a list with index numbers." | ||
+ "\n" | ||
+ "Parameters: " + "CUSTOMER_ID (must be a positive integer)" | ||
+ "\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ "1"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Listed %s completed tasks delivered to the Customer ID #%s"; | ||
|
||
private int customerId; | ||
|
||
public ViewCustomerTaskCommand(int customerId) { | ||
this.customerId = customerId; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
List<Customer> currentCustomerList = model.getFilteredCustomerList(); | ||
|
||
if (customerId > currentCustomerList.size()) { | ||
throw new CommandException(Messages.MESSAGE_INVALID_CUSTOMER_DISPLAYED_INDEX); | ||
} | ||
|
||
model.viewCustomerTask(customerId); | ||
int listSize = model.getCurrentCompletedTaskList().size(); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, listSize, customerId)); | ||
} | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/seedu/address/logic/parser/GoCommandParser.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,34 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.commands.GoCommand.HISTORY_TAB; | ||
import static seedu.address.logic.commands.GoCommand.HOME_TAB; | ||
|
||
import seedu.address.logic.commands.GoCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
/** | ||
* Parses input arguments and creates a new GoCommand object | ||
*/ | ||
public class GoCommandParser implements Parser<GoCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the GoCommand | ||
* and returns a GoCommand object for execution. | ||
* | ||
* @return the parsed command | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public GoCommand parse(String args) throws ParseException { | ||
|
||
String tabName = args.trim().toLowerCase(); | ||
if (tabName.equalsIgnoreCase(HOME_TAB)) { | ||
return new GoCommand(HOME_TAB); | ||
} else if (tabName.equalsIgnoreCase(HISTORY_TAB)) { | ||
return new GoCommand(HISTORY_TAB); | ||
} else { | ||
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, GoCommand.MESSAGE_USAGE)); | ||
} | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/seedu/address/logic/parser/ViewCustomerTaskCommandParser.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.address.logic.parser; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
|
||
import seedu.address.logic.commands.ViewCustomerTaskCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
/** | ||
* Parses input arguments and creates a new ViewCustomerTaskCommand object | ||
*/ | ||
public class ViewCustomerTaskCommandParser implements Parser<ViewCustomerTaskCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the ViewCustomerTaskCommand | ||
* and returns a ViewCustomerCommand object for execution. | ||
* | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public ViewCustomerTaskCommand parse(String args) throws ParseException { | ||
|
||
try { | ||
int customerId = ParserUtil.parseId(args); | ||
return new ViewCustomerTaskCommand((customerId)); | ||
} catch (ParseException pe) { | ||
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
ViewCustomerTaskCommand.MESSAGE_USAGE), pe); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/seedu/address/logic/parser/ViewDriverTaskCommandParser.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.address.logic.parser; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
|
||
import seedu.address.logic.commands.ViewDriverTaskCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
/** | ||
* Parses input arguments and creates a new ViewDriverTaskCommand object | ||
*/ | ||
public class ViewDriverTaskCommandParser implements Parser<ViewDriverTaskCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the ViewDriverTaskCommand | ||
* and returns a ViewDriverCommand object for execution. | ||
* | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public ViewDriverTaskCommand parse(String args) throws ParseException { | ||
|
||
try { | ||
int driverId = ParserUtil.parseId(args); | ||
return new ViewDriverTaskCommand((driverId)); | ||
} catch (ParseException pe) { | ||
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
ViewDriverTaskCommand.MESSAGE_USAGE), pe); | ||
} | ||
} | ||
} |
Oops, something went wrong.