Skip to content

Commit

Permalink
Merge pull request #209 from Joelwang22/branch-bugFix
Browse files Browse the repository at this point in the history
Bug Fixing
  • Loading branch information
Joelwang22 authored Apr 12, 2024
2 parents cc289f1 + 40fdb4b commit c8bc475
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ Format: `delete c/CUSTOMER_ID`
Examples:
* `list` followed by `delete c/2` deletes the person with customer_id of `2` in the address book.
* `find Betsy` followed by `delete c/1` deletes the person with customer_id of `1` in the results of the `find` command.
![Deleting customer 2](images/DeleteCommand.png)
![Result for deleting customer 2](images/DeleteCommandResult.png)
![Deleting customer 2](images/DeleteCommand.png)
![Result for deleting customer 2](images/DeleteCommandResult.png)

### Creating of orders: `order`

Expand All @@ -158,7 +158,7 @@ Format: `order p/PHONE_NUMBER [by/DEADLINE]`
* `DEADLINE` is an optional fields that is used to keep track of an order's deadline
* * The format for deadline dates are dd/MM/yyyy
* For single digit days or months, please precede them with a zero.
* Leaving Deadline blank will make the order's deadline marked as `Not Specified`
* Leaving `DEADLINE` blank will make the order's deadline marked as `Not Specified`
* Strack will prompt users to input products using the product command
* Follow up with products to be added to the order using the following format. Format: `product m/PRODUCT_ID pq/PRODUCT_QUANTITY`.
* You can refer to the Menu list for the product index, i.e. `1. Cupcake` product index is `1`.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public class Messages {
"Multiple values specified for the following single-valued field(s): ";

public static final String MESSAGE_INVALID_PHONE_NUMBER = "Phone number provided not found";
public static final String MESSAGE_INVALID_DATE = "Please specify a valid date.";

public static final String MESSAGE_PHONE_NUMBER_NOT_FOUND = "Phone number provided not found";
public static final String MESSAGE_ORDER_NOT_CREATED = "Please create an order before adding products.";
public static final String MESSAGE_LARGE_QUANTITY = "Quantity specified is too large, please try again.";

public static final String MESSAGE_ONLY_ONE_FIELD = "Only one field can be provided";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AddOrderCommand extends Command {
public static final String MESSAGE_ADD_PRODUCTS = "Add products using this command:"
+ "product m/[PRODUCT_ID] pq/[QUANTITY]";
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Edits the order of the person identified "
+ ": Creates an order for the person identified "
+ "by the phone number of person. "
+ "\n"
+ "Parameters: phone number (must be a positive integer) "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public CommandResult execute(Model model) throws CommandException {
if (lastOrder == null) {
throw new CommandException(Messages.MESSAGE_ORDER_NOT_CREATED);
}

Product product = model.findProductByIndex(productId.getZeroBased());
//Add ability to add product to order
if (lastOrder.getProductMap().containsKey(product)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class EditOrderCommand extends EditCommand {
public static final String MESSAGE_NOT_EDITED =
"Both product and quantity must be provided.";

public static final String MESSAGE_NOT_EDITED_EXTRA = "You can edit either product and quantity "
+ "or the order's deadline";
public static final String MESSAGE_NOT_EDITED_EXTRA = "Please provide either both product and quantity, "
+ "or the order's deadline to be edited";

private final Index orderIndex;
private final Index productIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_LARGE_QUANTITY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_MENU;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PRODUCT_QUANTITY;

Expand Down Expand Up @@ -39,6 +40,8 @@ public AddProductCommand parse(String args) throws ParseException {
try {
productId = ParserUtil.parseIndex(argMultimap.getValue(PREFIX_MENU).get());
quantity = ParserUtil.parseQuantity(argMultimap.getValue(PREFIX_PRODUCT_QUANTITY).get());
} catch (NumberFormatException e) {
throw new ParseException(String.format(MESSAGE_LARGE_QUANTITY), e);
} catch (IllegalValueException ive) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
AddProductCommand.MESSAGE_USAGE), ive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public EditOrderCommand parse(String args) throws ParseException {
if (!argMultimap.getValue(PREFIX_MENU).isPresent()
&& !argMultimap.getValue(PREFIX_PRODUCT_QUANTITY).isPresent()
&& !argMultimap.getValue(PREFIX_DEADLINE).isPresent()) {
throw new ParseException(EditOrderCommand.MESSAGE_NOT_EDITED);
throw new ParseException(EditOrderCommand.MESSAGE_NOT_EDITED_EXTRA);
}


Expand Down
12 changes: 10 additions & 2 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.Messages;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.exceptions.InvalidDateException;
import seedu.address.model.order.Deadline;
import seedu.address.model.order.Product;
import seedu.address.model.order.Quantity;
Expand Down Expand Up @@ -155,7 +156,8 @@ public static Quantity parseQuantity(String quantity) throws ParseException {
if (!Quantity.isValidQuantity(trimmedQuantity)) {
throw new ParseException(Quantity.MESSAGE_CONSTRAINTS);
}
return new Quantity(Integer.parseInt(trimmedQuantity));
int result = Integer.parseInt(trimmedQuantity);
return new Quantity(result);
}

/**
Expand Down Expand Up @@ -211,6 +213,12 @@ public static Deadline parseDeadline(String deadline) throws ParseException {
if (!Deadline.isValidDeadline(trimmedDeadline)) {
throw new ParseException(Deadline.MESSAGE_CONSTRAINTS);
}
return new Deadline(trimmedDeadline);
Deadline result;
try {
result = new Deadline(trimmedDeadline);
} catch (InvalidDateException e) {
throw new ParseException(String.format(Messages.MESSAGE_INVALID_DATE));
}
return result;
}
}
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/order/Quantity.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ public void setQuantity(int newQuantity) {
public static boolean isValidQuantity(String test) {
return test.matches(VALIDATION_REGEX);
}

}
3 changes: 1 addition & 2 deletions src/main/resources/view/OrderListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>

<HBox id="cardPane" fx:id="cardPane" prefWidth="150.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1"
stylesheets="Styles.css">
<HBox id="cardPane" fx:id="cardPane" prefWidth="150.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<GridPane prefWidth="150.0" HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
Expand Down
15 changes: 0 additions & 15 deletions src/main/resources/view/Styles.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class EditOrderCommandParserTest {
@Test
public void parse_missingParts_failure() {
// no field specified
assertParseFailure(parser, " " + PREFIX_ORDER + "1", EditOrderCommand.MESSAGE_NOT_EDITED);
assertParseFailure(parser, " " + PREFIX_ORDER + "1", EditOrderCommand.MESSAGE_NOT_EDITED_EXTRA);

// no index and no field specified
assertParseFailure(parser, "", MESSAGE_INVALID_FORMAT);
Expand Down

0 comments on commit c8bc475

Please sign in to comment.