标签:
用途
图-备忘录模式结构图
测试
public class MementoPattern { public static void main(String[] args) { Originator o = new Originator(); o.SetState("ON"); o.Show(); Caretaker c = new Caretaker(); c.SetMemento(o.CreateMemento()); o.SetState("OFF"); o.Show(); o.SetMemento(c.GetMemento()); o.Show(); } }
测试结果
State = ON State = OFF State = ON
标签:
原文地址:http://www.cnblogs.com/tfl-511/p/5889674.html