memento.java

来自「源码为科学出版社出版的英文<java设计模式>(影印版)所用的所有例」· Java 代码 · 共 21 行

JAVA
21
字号
public class Memento {
    visRectangle rect;
    /**saved fields- remember internal fields
    of the specified visual rectangle
    */

    private int x, y, w, h;
    public Memento(visRectangle r) {
        rect = r;
        x = rect.x;  y = rect.y;
        w = rect.w;  h = rect.h;
    }
    //-------------------------------------------
    public void restore() {
        //restore the internal state of
        //the specified rectangle
        rect.x = x;  rect.y = y;
        rect.h = h;  rect.w = w;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?