Skip to content

Commit

Permalink
Merge 7059c4d into 1c6ce53
Browse files Browse the repository at this point in the history
  • Loading branch information
Krit-K committed Nov 8, 2019
2 parents 1c6ce53 + 7059c4d commit 4857ca4
Show file tree
Hide file tree
Showing 25 changed files with 517 additions and 75 deletions.
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public interface Logic {
/** Returns an unmodifiable view of the filtered list of assigned task list */
ObservableList<Task> getFilteredAssignedTaskList();

/** Returns an unmodifiable view of the filtered list of unassigned task list */
ObservableList<Task> getFilteredCompletedTaskList();

/** Returns an unmodifiable view of the filtered list of drivers*/
ObservableList<Driver> getFilteredDriverList();

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public ObservableList<Task> getFilteredAssignedTaskList() {
return model.getAssignedTaskList();
}

@Override
public ObservableList<Task> getFilteredCompletedTaskList() {
return model.getCompletedTaskList();
}

@Override
public ObservableList<Task> getIncompleteTaskList() {
return model.getIncompleteTaskList();
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/seedu/address/logic/commands/CommandResult.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.commands.GoCommand.DEFAULT_TAB;

import java.util.Objects;

Expand All @@ -10,20 +11,30 @@
public class CommandResult {

private final String feedbackToUser;
private String tabType;

/** Help information should be shown to the user. */
private final boolean showHelp;


/** The application should exit. */
private final boolean exit;

public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.showHelp = showHelp;
this.exit = exit;
this.tabType = DEFAULT_TAB;
}

/**
* Constructs a {@code CommandResult} with the specified fields.
*/
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit, String tabType) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.showHelp = showHelp;
this.exit = exit;
this.tabType = tabType;
}

/**
Expand All @@ -38,6 +49,10 @@ public String getFeedbackToUser() {
return feedbackToUser;
}

public String getTabType() {
return tabType;
}

public boolean isShowHelp() {
return showHelp;
}
Expand All @@ -46,6 +61,10 @@ public boolean isExit() {
return exit;
}

public boolean isSwitchTab() {
return !tabType.equals(DEFAULT_TAB);
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/seedu/address/logic/commands/GoCommand.java
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);
}

}
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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,43 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Driver;
import seedu.address.model.task.Task;

/**
* List delivered task for specified driver
* List completed delivery task allocated to the particular driver.
*/
public class ViewDriverTasksCommand extends Command {
public class ViewDriverTaskCommand extends Command {

public static final String COMMAND_WORD = "viewD";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Views the delivered tasks of the specified driver "
+ "and displays them as a list with index numbers.\n"
+ "Parameters: INDEX (must be a positive integer)"
+ "Example: " + COMMAND_WORD + " 1";
+ "and displays them as a list with index numbers."
+ "\n"
+ "Parameters: " + "DRIVER_ID (must be a positive integer)"
+ "\n"
+ "Example: " + COMMAND_WORD + " "
+ "1";

public static final String MESSAGE_SUCCESS = "listed delivered tasks";
public static final String MESSAGE_SUCCESS = "Listed %s completed tasks assigned to the Driver ID #%s";

private int driverId;

public ViewDriverTasksCommand(int driverId) {
public ViewDriverTaskCommand(int driverId) {
this.driverId = driverId;
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

List<Driver> currentDriverList = model.getFilteredDriverList();
List<Task> taskList = model.getFilteredTaskList();

if (driverId > currentDriverList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_DRIVER_DISPLAYED_INDEX);
}

Driver driverToView = currentDriverList.get(driverId);
model.viewDriverTask(driverToView);
return new CommandResult(String.format(MESSAGE_SUCCESS, driverToView));
model.viewDriverTask(driverId);
int listSize = model.getCurrentCompletedTaskList().size();
return new CommandResult(String.format(MESSAGE_SUCCESS, listSize, driverId));
}

}
13 changes: 13 additions & 0 deletions src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
import seedu.address.logic.commands.FindCustomerCommand;
import seedu.address.logic.commands.FindDriverCommand;
import seedu.address.logic.commands.FreeCommand;
import seedu.address.logic.commands.GoCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.ReadIdCommand;
import seedu.address.logic.commands.SavePdfCommand;
import seedu.address.logic.commands.SuggestCommand;
import seedu.address.logic.commands.ViewCustomerTaskCommand;
import seedu.address.logic.commands.ViewDriverTaskCommand;

import seedu.address.logic.parser.exceptions.ParseException;

/**
Expand Down Expand Up @@ -106,6 +110,15 @@ public Command parseCommand(String userInput) throws ParseException {
case ClearCommand.COMMAND_WORD:
return new ClearCommandParser().parse(arguments);

case ViewCustomerTaskCommand.COMMAND_WORD:
return new ViewCustomerTaskCommandParser().parse(arguments);

case ViewDriverTaskCommand.COMMAND_WORD:
return new ViewDriverTaskCommandParser().parse(arguments);

case GoCommand.COMMAND_WORD:
return new GoCommandParser().parse(arguments);

case ExitCommand.COMMAND_WORD:
return new ExitCommand();

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/seedu/address/logic/parser/GoCommandParser.java
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));
}
}

}
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);
}
}
}
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);
}
}
}
Loading

0 comments on commit 4857ca4

Please sign in to comment.