Java Reference
In-Depth Information
Figure 19.2. A Visualization object lets a user paint a picture of a prospective factory.
When the user clicks Add or drags and releases a machine image, the Visualization
object asks the FactoryModel object for a new memento. The Visualization object
stacks this memento. When the user clicks Undo, the Visualization object pops
amemento and calls the FactoryModel object's restore() method, passing in
the memento at the new top of the stack. The FactoryModel object creates a memento by
creating a list and populating it with clones of the current MachineImage objects in its
machines list.
Write the code for the createMemento() method of FactoryModel so that
the method returns a List of clones of machine simulators.
The counterpart to a createMemento() method is a restore() method that restores the
state of the object according to the information in the memento. In this example, the memento
Search WWH ::

Custom Search