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
<divmarkdown="span"class="alert alert-info">:information_source: **Note:** In the sequence diagram, the details of `LabList#setLab` have been intentionally omitted. They can be found in the sequence diagram below.
304
+
</div>
305
+
306
+
The following sequence diagram shows how `LabList#setLab` is implemented:
The proposed undo/redo mechanism is facilitated by `VersionedAddressBook`. It extends `AddressBook` with an undo/redo history, stored internally as an `addressBookStateList` and `currentStatePointer`. Additionally, it implements the following operations:
324
+
325
+
*`VersionedAddressBook#commit()` — Saves the current TAddressBook state in its history.
326
+
*`VersionedAddressBook#undo()` — Restores the previous TAddressBook state from its history.
327
+
*`VersionedAddressBook#redo()` — Restores a previously undone TAddressBook state from its history.
328
+
329
+
These operations are exposed in the `Model` interface as `Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively.
330
+
331
+
Given below is an example usage scenario and how the undo/redo mechanism behaves at each step.
332
+
333
+
Step 1. The user launches the application for the first time. The `VersionedAddressBook` will be initialized with the initial TAddressBook state, and the `currentStatePointer` pointing to that single TAddressBook state.
334
+
335
+

336
+
337
+
Step 2. The user executes `delete 5` command to delete the 5th student in the TAddressBook. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the TAddressBook after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted TAddressBook state.
338
+
339
+

340
+
341
+
Step 3. The user executes `add n/David …` to add a new student. The `add` command also calls `Model#commitAddressBook()`, causing another modified TAddressBook state to be saved into the `addressBookStateList`.
0 commit comments