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

📄 commandlist.java

📁 这个文件里面包含了java设计模式的一些例子讲解
💻 JAVA
字号:
package com.javapatterns.command.drawapplet;

import java.util.Stack;

public class CommandList
{
    private	Stack executedCommands = new Stack();
    private	Stack unexecutedCommands = new Stack();

	private void _execute( Command command )
    {
        command.execute();
        executedCommands.push( command );
    }

	public void execute( Command command )
	{
        unexecutedCommands.removeAllElements();
        _execute( command );
    }

	public void unexecute()
	{
        Command command = (Command)executedCommands.pop();
        command.unexecute();
        unexecutedCommands.push( command );
    }

	public void reexecute()
	{
        Command command = (Command)unexecutedCommands.pop();
        _execute( command );
    }

	public void reset()
	{
        executedCommands.removeAllElements();
        unexecutedCommands.removeAllElements();
    }

    public boolean canUnexecuteCommand()
    {
        return !executedCommands.empty();
    }

    public boolean canReexecuteCommand()
    {
        return !unexecutedCommands.empty();
    }
}

⌨️ 快捷键说明

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