You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/DeveloperGuide.md
+25-26Lines changed: 25 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -455,51 +455,50 @@ The following UML sequence diagram shows how the `edit-loan BOOK_TITLE [n/BORROW
455
455
456
456
The `update-title` feature allows the user to update existing book titles. The system ensures that a book of the current title exists in the inventory and before performing the update.
457
457
458
-
`InputHandler` coordinates with `InputParser`, `BookList`, `Formatter`, and `Storage` classes to implement the feature.
458
+
`InputHandler` coordinates with `InputParser`, `BookList`, `Book`, `Formatter`, and `Storage` classes to implement the feature.
459
459
460
-
The following UML sequence diagram shows how the `update-book BOOK_TITLE [a/AUTHOR] [cat/CATEGORY] [cond/CONDITION] [loc/LOCATION] [note/NOTE]` command is handled.
460
+
The following UML sequence diagram shows how the `update-book BOOK_TITLE new/NEW_TITLE` command is handled.
461
461
462
-

462
+

463
463
464
464
1. User issues command:
465
-
The user inputs the command in the CLI with the required arguments, e.g., `update-book The Great Gatsby a/F. Scott Fitzgerald cat/Fiction cond/POOR loc/Shelf B3 note/Replace ASAP`.
465
+
The user inputs the command in the CLI with the required arguments, e.g., `update-title BOOK_TITLE new/NEW_TITLE`.
466
466
467
467
2. Command arguments are extracted:
468
468
`InputHandler` first calls `InputParser.extractCommandArgs(...)` to split the user input into command arguments.
469
469
470
-
- For example, the input `update-book The Great Gatsby a/F. Scott Fitzgerald cat/Fiction cond/POOR loc/Shelf B3 note/Replace ASAP` is split into:
471
-
-`commandArgs[0]`: `"update-book"`
472
-
-`commandArgs[1]`: `"The Great Gatsby a/F. Scott Fitzgerald cat/Fiction cond/POOR loc/Shelf B3 note/Replace ASAP"`
470
+
- For example, the input `update-title Great Gatsby new/The Great Gatsby` is split into:
471
+
-`commandArgs[0]`: `"update-title"`
472
+
-`commandArgs[1]`: `"Great Gatsby new/The Great Gatsby"`
473
473
474
-
3.Book arguments are parsed:
475
-
`InputHandler` invokes `InputParser.extractUpdateBookArgs(...)` to parse the second part of the command (`commandArgs[1]`) into the following components:
474
+
3.Title arguments are parsed:
475
+
`InputHandler` invokes `InputParser.extractUpdateTitleArgs(...)` to parse the second part of the command (`commandArgs[1]`) into the following components:
476
476
477
-
- Book title
478
-
- Author
479
-
- Category
480
-
- Condition
481
-
- Location
482
-
- Note (Optional)
477
+
- old Title
478
+
- new Title
483
479
484
-
4. Book is validated:
485
-
`InputHandler` calls `BookList.findBookByTitle(bookTitle)` to check if the book exists in the inventory.
480
+
4. Title is validated:
481
+
`InputHandler` checks if `oldTitle` is the same as `newTitle`. `InputHandler` also calls `BookList.findBookByTitle(newTitle)` to check if there is an existing book with the same title as `newTitle`.
482
+
483
+
- If the a `oldTitle` and `newTitle` are the same, `InputHandler` uses `Formatter` to print a exception message and exits early.
484
+
- If the a book with the same title as `newTitle` is found, `InputHandler` uses `Formatter` to print a exception message and exits early.
485
+
- If no book is found, the flow continues.
486
+
487
+
5. Book is validated:
488
+
`InputHandler` calls `BookList.findBookByTitle(oldTitle)` to check if the book exists in the inventory.
486
489
487
490
- If the book is not found, `InputHandler` uses `Formatter` to print a exception message and exits early.
488
491
- If the book is found, the flow continues.
489
492
490
-
5. Book is updated:
493
+
6. Title is updated:
491
494
`InputHandler` updates the book details by invoking the following methods from `Book` class:
492
495
493
-
-`Book.setAuthor(newAuthor)`
494
-
-`Book.setCategory(newCategory)`
495
-
-`Book.setCondition(newCondition)`
496
-
-`Book.setLocation(newLocation)`
497
-
-`Book.setNote(newNote)` (only if note is provided)
496
+
-`Book.setTitle(newTitle)`
498
497
499
-
6. Changes are saved to persistent storage:
500
-
`InputHandler` calls `Storage.saveLoans(...)` and `Storage.saveInventory(...)` to save the updated book details.
498
+
7. Changes are saved to persistent storage:
499
+
`InputHandler` calls `Storage.saveLoans(...)` and `Storage.saveInventory(...)` to save the updated book title.
501
500
502
-
7. Success message is displayed:
501
+
8. Success message is displayed:
503
502
`InputHandler` uses `Formatter` to print a message indicating that the book was successfully updated.
0 commit comments