From 8c479934afabb61e2fdd254a5d9cd9f6e61c8b6f Mon Sep 17 00:00:00 2001 From: Julius Bryan <67666355+juliusgambe@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:27:25 +0800 Subject: [PATCH] Add overflow error --- .../customer/CustomerDeleteCommand.java | 14 ++++----- .../customer/CustomerEditCommand.java | 24 ++++++++------- .../delivery/DeliveryDeleteCommand.java | 8 +++-- .../delivery/DeliveryEditCommand.java | 29 ++++++++++--------- .../delivery/DeliveryViewCommand.java | 2 +- .../address/logic/parser/ParserUtil.java | 2 +- 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java b/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java index 6c0f22f61a8..300d9f06899 100644 --- a/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java @@ -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. @@ -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()) { @@ -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); } /** @@ -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(); } } diff --git a/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java b/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java index 323da048050..42187332067 100644 --- a/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java +++ b/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java @@ -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 + " johndoe@example.com"; + + "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 + " johndoe@example.com"; /** * The text to the message displayed when the Customer is edited successfuly. @@ -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 */ @@ -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 diff --git a/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java b/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java index 71130837673..3e2380559ba 100644 --- a/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java @@ -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. @@ -44,6 +44,7 @@ public class DeliveryDeleteCommand extends DeliveryCommand { /** * Creates a DeliveryDeleteCommand to delete the specified {@code Delivery} + * * @param targetIndex */ public DeliveryDeleteCommand(Index targetIndex) { @@ -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. diff --git a/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java b/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java index 529fc155fd3..72d96f68fb5 100644 --- a/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java +++ b/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java @@ -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!"; @@ -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 */ @@ -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); } diff --git a/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java b/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java index e952977ab2c..a597f26ec86 100644 --- a/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java +++ b/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java @@ -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"; diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index cf9b2f2ef73..6ab0f5fc1e8 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -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."; /**