diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index a0714ce5b7..ceb0e25308 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -394,7 +394,7 @@ The following sequence diagram shows the execution of a RenameCommand
1. The `SuperTracker` class calls the `execute` method of `RenameCommand` 2. The item object of the item to be renamed is obtained from `Inventory` -3. The quantity, price and expiry date are obtained from the item +3. The old name, quantity, price and expiry date are obtained from the item 4. A new `Item` object with the given parameters (newName, quantity, price, expiry date) is created and returned to `RenameCommand` 5. The `delete` method of the `Inventory` class is called to delete the old item 6. The `put` method of the `Inventory` class is called to put the new item into the inventory diff --git a/docs/uml-diagrams/RenameCommand.puml b/docs/uml-diagrams/RenameCommand.puml index a5cc84c3b2..9ba7a9543f 100644 --- a/docs/uml-diagrams/RenameCommand.puml +++ b/docs/uml-diagrams/RenameCommand.puml @@ -81,6 +81,11 @@ activate Inventory #d5eac2 Inventory --> RenameCommand : oldItem:Item deactivate Inventory +RenameCommand -> oldItem: getName() +activate oldItem #ffa1a1 +oldItem --> RenameCommand: oldName:String +deactivate oldItem + RenameCommand -> oldItem: getQuantity() activate oldItem #ffa1a1 oldItem --> RenameCommand: quantity:int @@ -111,7 +116,7 @@ activate Inventory #d5eac2 Inventory --> RenameCommand deactivate Inventory -RenameCommand -> Ui : renameCommandSuccess(item:Item) +RenameCommand -> Ui : renameCommandSuccess(newItem:Item, oldName:String) activate Ui #e5c2ea Ui --> RenameCommand deactivate Ui diff --git a/docs/uml-diagrams/RenameCommandSequence.png b/docs/uml-diagrams/RenameCommandSequence.png index 0d5b62c318..9896c227d8 100644 Binary files a/docs/uml-diagrams/RenameCommandSequence.png and b/docs/uml-diagrams/RenameCommandSequence.png differ diff --git a/src/main/java/supertracker/command/RenameCommand.java b/src/main/java/supertracker/command/RenameCommand.java index 5c99c7ea09..922bf5263e 100644 --- a/src/main/java/supertracker/command/RenameCommand.java +++ b/src/main/java/supertracker/command/RenameCommand.java @@ -32,6 +32,7 @@ public void execute() { assert Inventory.contains(name); Item oldItem = Inventory.get(name); + String oldName = oldItem.getName(); int quantity = oldItem.getQuantity(); double price = oldItem.getPrice(); LocalDate expiryDate = oldItem.getExpiryDate(); @@ -40,7 +41,7 @@ public void execute() { Inventory.delete(name); Inventory.put(newName, newItem); - Ui.renameCommandSuccess(newItem, name); + Ui.renameCommandSuccess(newItem, oldName); try { ItemStorage.saveData();