forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #538 from AY2324S1-CS2103T-T13-3/534-code-quality-…
…final 534 code quality final
- Loading branch information
Showing
44 changed files
with
494 additions
and
445 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//@@author {zhonghan721} | ||
package seedu.address.logic.commands.customer; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
@@ -24,16 +25,16 @@ public class CustomerAddCommand extends CustomerCommand { | |
public static final String COMMAND_WORD = CustomerCommand.COMMAND_WORD + " " + "add"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a customer to the HomeBoss database." | ||
+ "\n\nParameters: " | ||
+ PREFIX_NAME + " NAME " | ||
+ PREFIX_PHONE + " PHONE " | ||
+ PREFIX_EMAIL + " EMAIL " | ||
+ PREFIX_ADDRESS + " ADDRESS\n\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + " John Doe " | ||
+ PREFIX_PHONE + " 98765432 " | ||
+ PREFIX_EMAIL + " [email protected] " | ||
+ PREFIX_ADDRESS + " 311, Clementi Ave 2, #02-25"; | ||
+ "\n\nParameters: " | ||
+ PREFIX_NAME + " NAME " | ||
+ PREFIX_PHONE + " PHONE " | ||
+ PREFIX_EMAIL + " EMAIL " | ||
+ PREFIX_ADDRESS + " ADDRESS\n\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + " John Doe " | ||
+ PREFIX_PHONE + " 98765432 " | ||
+ PREFIX_EMAIL + " [email protected] " | ||
+ PREFIX_ADDRESS + " 311, Clementi Ave 2, #02-25"; | ||
|
||
public static final String MESSAGE_SUCCESS = "New customer added:\n\n%1$s"; | ||
public static final String MESSAGE_DUPLICATE_CUSTOMER = "This customer already exists in HomeBoss"; | ||
|
@@ -53,10 +54,10 @@ public CustomerAddCommand(Customer customer) { | |
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
logger.info("Executing CustomerAddCommand: name " | ||
+ toAdd.getName() + ", phone " | ||
+ toAdd.getPhone() + ", email " | ||
+ toAdd.getEmail() + ", address " | ||
+ toAdd.getAddress()); | ||
+ toAdd.getName() + ", phone " | ||
+ toAdd.getPhone() + ", email " | ||
+ toAdd.getEmail() + ", address " | ||
+ toAdd.getAddress()); | ||
|
||
// User cannot perform this operation before logging in | ||
if (!model.getUserLoginStatus()) { | ||
|
@@ -95,7 +96,8 @@ public boolean equals(Object other) { | |
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this) | ||
.add("toAdd", toAdd) | ||
.toString(); | ||
.add("toAdd", toAdd) | ||
.toString(); | ||
} | ||
} | ||
//@@author {zhonghan721} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//@@author {Gabriel4357} | ||
package seedu.address.logic.commands.customer; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
@@ -45,16 +46,16 @@ public class CustomerEditCommand extends CustomerCommand { | |
* 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 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]"; | ||
+ "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. | ||
|
@@ -120,7 +121,13 @@ public CommandResult execute(Model model) throws CommandException { | |
Customer customerToEdit = targetCustomer.get(); | ||
Customer editedCustomer = createEditedCustomer(customerToEdit, customerEditDescriptor); | ||
|
||
if (!customerToEdit.hasSamePhone(editedCustomer) && model.hasCustomerWithSamePhone(editedCustomer)) { | ||
logger.info("Customer to be edited: " + customerToEdit.toString() + "\n"); | ||
logger.info("Edited Customer: " + editedCustomer.toString() + "\n"); | ||
|
||
boolean isExistingCustomer = !customerToEdit.hasSamePhone(editedCustomer) | ||
&& model.hasCustomerWithSamePhone(editedCustomer); | ||
|
||
if (isExistingCustomer) { | ||
logger.warning("Customer to be edited already exist.(has the same phone number as another customer)." | ||
+ "\n"); | ||
throw new CommandException(MESSAGE_DUPLICATE_PERSON); | ||
|
@@ -129,17 +136,12 @@ public CommandResult execute(Model model) throws CommandException { | |
assert customerToEdit != null : "Customer to be edited should exist."; | ||
assert editedCustomer != null : "Edited Customer should exist."; | ||
|
||
logger.info("Customer to be edited: " + customerToEdit.toString() + "\n"); | ||
logger.info("Edited Customer: " + editedCustomer.toString() + "\n"); | ||
|
||
model.setCustomer(customerToEdit, editedCustomer); | ||
updateDelivery(model, editedCustomer); | ||
model.showAllFilteredCustomerList(); | ||
|
||
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, | ||
Messages.format(editedCustomer)), true); | ||
|
||
|
||
} | ||
|
||
/** | ||
|
@@ -178,11 +180,14 @@ protected static void updateDelivery(Model model, Customer editedCustomer) { | |
}); | ||
} | ||
|
||
|
||
//@@author {zhonghan721} | ||
|
||
/** | ||
* Creates and returns a {@code Delivery} with the customer details edited. | ||
* | ||
* @param deliveryToEdit {@code Delivery} which the command edits. | ||
* @param editedCustomer {@code Customer} which the delivery is associated with. | ||
* @param deliveryToEdit {@code Delivery} which the command edits. | ||
* @param editedCustomer {@code Customer} which the delivery is associated with. | ||
*/ | ||
private static Delivery createEditedDelivery(Delivery deliveryToEdit, Customer editedCustomer) { | ||
|
||
|
@@ -205,6 +210,7 @@ private static Delivery createEditedDelivery(Delivery deliveryToEdit, Customer e | |
return new Delivery(deliveryToEdit.getDeliveryId(), deliveryName, editedCustomer, orderDate, | ||
deliveryDate, deliveryStatus, note); | ||
} | ||
//@@author {zhonghan721} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
|
@@ -333,3 +339,4 @@ public String toString() { | |
} | ||
} | ||
} | ||
//@@author {Gabriel4357} |
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
Oops, something went wrong.