public void Run() { State s = new State(); s.A = "a"; Originator o = new Originator(s); o.Show(); Mementor m = o.CraeteMementor(); CareTaker c = new CareTaker(); c.Add(m); s.A = "b"; o.ChangeStatus(s); o.Show(); Mementor tm = (Mementor)c.Restore(); o.SetState(tm); o.Show(); }
public Mementor(State st) { this.state = (State)st.Clone(); }
public object Clone() { State state = new State(); state.A = a; return state; }
public void SetState(Mementor m) { this.state = m._State; }
public void ChangeStatus(State s) { this.state = s; }
public Originator(State st) { this.state = (State)st.Clone(); }