public override void execute() { Student student = new Student("Alice", 1, "Run"); StudentMomento SM = student.createMomento(); CareTaker.studentMomento = SM;//save to memory... Console.WriteLine("Before set Id to null :"); student.showProps(); Console.WriteLine("------------------------"); student.Id = null; //blah blah blah... Console.WriteLine("After set Id to null :"); student.showProps(); Console.WriteLine("------------------------"); //restore back the student student.setMomento(CareTaker.studentMomento); Console.WriteLine("After restore :"); student.showProps(); }
public void setMomento(StudentMomento studentMomento) { this.setStudent(studentMomento.Name, studentMomento.Id, studentMomento.Action); }