⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 undocommand.java

📁 源码为科学出版社出版的英文<java设计模式>(影印版)所用的所有例子程序
💻 JAVA
字号:
import java.util.*;

public class undoCommand implements Command {
   Vector undoList;
   
   public undoCommand(){
      undoList = new Vector();      //list of commands to undo
   }                 
   //-----------------------------
   public void add(Command cmd) {
      if(! (cmd instanceof undoCommand))
         undoList.add(cmd);         //add commands into list
   }
   //-----------------------------
   public void Execute() {
      int index = undoList.size () -1;
       
      if (index >=  0) {
         //get last command executed
         Command cmd =  (Command)undoList.elementAt (index);
         cmd.unDo ();               //undo it
         undoList.remove (index);   //and remove from list
      } 
   }
   //-----------------------------
   public void unDo() {    //does nothing
   }
}

⌨️ 快捷键说明

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