package com.xfcz.behaviour.memento.blankbox;
public class Originator {
private String state;
public IMemento createMemento(){
return new Memento(state);
}
public void restoreMemento(IMemento menmento){
this.setState(((Memento)menmento).getState());
}
public String getState() {
return state;
}
public void setState(String state) {
System.out.println("当前状态:"+state);
this.state = state;
}
private class Memento implements IMemento{
private String state;
public Memento(String state){
setState(state);
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
}