Skip to content

Commit

Permalink
Merge pull request #543 from juliusgambe/533-bug-integer-overflow
Browse files Browse the repository at this point in the history
Add overflow error
  • Loading branch information
jianyangg authored Nov 13, 2023
2 parents 9c07b1f + 8c47993 commit 41014b5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class CustomerDeleteCommand extends CustomerCommand {
* The message usage of the delete customer command.
*/
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the customer identified by the customer ID used in the displayed customer list.\n\n"
+ "Parameters: CUSTOMER_ID (must be a positive integer)\n\n"
+ "Example: " + COMMAND_WORD + " 1";
+ ": Deletes the customer identified by the customer ID used in the displayed customer list.\n\n"
+ "Parameters: CUSTOMER_ID (must be a positive integer and less than 2147483648)\n\n"
+ "Example: " + COMMAND_WORD + " 1";

/**
* The pre-text to the message displayed when the customer is deleted successfully.
Expand Down Expand Up @@ -69,7 +69,7 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

logger.info("Executing CustomerDeleteCommand:"
+ " customerID: " + customerID.getOneBased() + "\n");
+ " customerID: " + customerID.getOneBased() + "\n");

// User cannot perform this operation before logging in
if (!model.getUserLoginStatus()) {
Expand All @@ -90,7 +90,7 @@ public CommandResult execute(Model model) throws CommandException {

model.deleteCustomer(customerToDelete.get());
return new CommandResult(String.format(MESSAGE_DELETE_CUSTOMER_SUCCESS,
Messages.format(customerToDelete.get())), true);
Messages.format(customerToDelete.get())), true);
}

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ public boolean equals(Object other) {
@Override
public String toString() {
return new ToStringBuilder(this)
.add("customerID", customerID)
.toString();
.add("customerID", customerID)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public class CustomerEditCommand extends CustomerCommand {
public static final String COMMAND_WORD = CustomerCommand.COMMAND_WORD + " " + "edit";

/**
* The text displayed to show what the command does and how to use it.
* The text displayed to show what the command does and how to use it.
*/
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified "
+ "by the customer ID used in the displayed person list. "
+ "Existing values will be overwritten by the input values.\n\n"
+ "Parameters: CUSTOMER_ID (must be a positive integer) "
+ "[" + PREFIX_NAME + " NAME] "
+ "[" + PREFIX_PHONE + " PHONE] "
+ "[" + PREFIX_EMAIL + " EMAIL] "
+ "[" + PREFIX_ADDRESS + " ADDRESS]\n\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + " 91234567 "
+ PREFIX_EMAIL + " [email protected]";
+ "by the customer ID used in the displayed person list. "
+ "Existing values will be overwritten by the input values.\n\n"
+ "Parameters: CUSTOMER_ID (must be a positive integer and less than 2147483648) "
+ "[" + PREFIX_NAME + " NAME] "
+ "[" + PREFIX_PHONE + " PHONE] "
+ "[" + PREFIX_EMAIL + " EMAIL] "
+ "[" + PREFIX_ADDRESS + " ADDRESS]\n\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + " 91234567 "
+ PREFIX_EMAIL + " [email protected]";

/**
* The text to the message displayed when the Customer is edited successfuly.
Expand All @@ -73,6 +73,7 @@ public class CustomerEditCommand extends CustomerCommand {

/**
* Creates a CustomerEditCommand to edit the customers.
*
* @param targetIndex of the person in the filtered person list to edit
* @param customerEditDescriptor details to edit the person with
*/
Expand All @@ -86,6 +87,7 @@ public CustomerEditCommand(Index targetIndex, CustomerEditDescriptor customerEdi

/**
* Executes the CustomerEditCommand.
*
* @param model {@code Model} which the command should operate on.
* @return The command result along with the message to be displayed to the user.
* @throws CommandException If the user is not logged in or if the customer does not exist or if the edited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class DeliveryDeleteCommand extends DeliveryCommand {
public static final String COMMAND_WORD = DeliveryCommand.COMMAND_WORD + " " + "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the delivery identified by the delivery ID used in the displayed delivery list.\n\n"
+ "Parameters: DELIVERY_ID (must be a positive integer)\n\n"
+ "Example: " + COMMAND_WORD + " 1";
+ ": Deletes the delivery identified by the delivery ID used in the displayed delivery list.\n\n"
+ "Parameters: DELIVERY_ID (must be a positive integer and less than 2147483648)\n\n"
+ "Example: " + COMMAND_WORD + " 1";

/**
* The text to the message displayed when the Delivery is delete successfuly.
Expand All @@ -44,6 +44,7 @@ public class DeliveryDeleteCommand extends DeliveryCommand {

/**
* Creates a DeliveryDeleteCommand to delete the specified {@code Delivery}
*
* @param targetIndex
*/
public DeliveryDeleteCommand(Index targetIndex) {
Expand All @@ -52,6 +53,7 @@ public DeliveryDeleteCommand(Index targetIndex) {

/**
* Executes the DeliveryDeleteCommand.
*
* @param model {@code Model} which the command should operate on.
* @return The command result along with the message to be displayed to the user.
* @throws CommandException If the delivery to be deleted does not exist or the user is not logged in.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ public class DeliveryEditCommand extends DeliveryCommand {
* The text displayed to show what the command does and how to use it.
*/
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the delivery identified "
+ "by the DELIVERY_ID used in the displayed delivery list. "
+ "Existing values will be overwritten by the input values.\n\n"
+ "Parameters: DELIVERY_ID (must be a positive integer)\n\n"
+ "At least one field must be specified."
+ "[" + PREFIX_NAME + " DELIVERY_NAME] "
+ "[" + PREFIX_CUSTOMER_ID + " CUSTOMER_ID] "
+ "[" + PREFIX_DATE + " DELIVERY_DATE] "
+ "[" + PREFIX_STATUS + " STATUS] "
+ "[" + PREFIX_NOTE + " NOTE]...\n\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_NAME + " 10 Chocolate Cakes "
+ PREFIX_DATE + " 2025-12-12";
+ "by the DELIVERY_ID used in the displayed delivery list. "
+ "Existing values will be overwritten by the input values.\n\n"
+ "Parameters: DELIVERY_ID (must be a positive integer and less than 2147483648)\n\n"
+ "At least one field must be specified."
+ "[" + PREFIX_NAME + " DELIVERY_NAME] "
+ "[" + PREFIX_CUSTOMER_ID + " CUSTOMER_ID] "
+ "[" + PREFIX_DATE + " DELIVERY_DATE] "
+ "[" + PREFIX_STATUS + " STATUS] "
+ "[" + PREFIX_NOTE + " NOTE]...\n\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_NAME + " 10 Chocolate Cakes "
+ PREFIX_DATE + " 2025-12-12";

/**
* The text to the message displayed when the Delivery is edited successfuly.
* The text to the message displayed when the Delivery is edited successfuly.
*/
public static final String MESSAGE_EDIT_DELIVERY_SUCCESS = "Edited Delivery:\n\n%1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field must be provided!";
Expand All @@ -70,6 +70,7 @@ public class DeliveryEditCommand extends DeliveryCommand {

/**
* Creates a DeliveryEditCommand to edit the specified {@code Delivery}
*
* @param targetIndex of the delivery in the delivery list to edit
* @param deliveryEditDescriptor details to edit the delivery with
*/
Expand Down Expand Up @@ -115,7 +116,7 @@ public CommandResult execute(Model model) throws CommandException {
model.showAllFilteredDeliveryList();

return new CommandResult(String.format(MESSAGE_EDIT_DELIVERY_SUCCESS,
Messages.format(editedDelivery)), true);
Messages.format(editedDelivery)), true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DeliveryViewCommand extends DeliveryCommand {
public static final String COMMAND_WORD = DeliveryCommand.COMMAND_WORD + " view";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Displays a single delivery order.\n\n"
+ "Parameters: "
+ "DELIVERY_ID (Must be a positive integer)\n\n"
+ "DELIVERY_ID (Must be a positive integer and less than 2147483648)\n\n"
+ "Example: " + COMMAND_WORD + " "
+ "1";

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public class ParserUtil {

public static final String MESSAGE_INVALID_INDEX = "ID must be an integer more than 0.";
public static final String MESSAGE_INVALID_INDEX = "ID must be an integer more than 0 and less than 2147483648.";


/**
Expand Down

0 comments on commit 41014b5

Please sign in to comment.