macroaudiocommand.java

来自「《JAVA与模式》附书中源代码」· Java 代码 · 共 38 行

JAVA
38
字号
package com.javapatterns.command.audioplayer2;

import java.util.Vector;

public class MacroAudioCommand implements MacroCommand
{
     private Vector commandList = new Vector();

     public void add(Command toAdd)
     {          
		commandList.addElement(toAdd);
     }

     public void remove(int index)
     {
		commandList.remove(index);
     }

     public void remove(Command toRemove)
     {
		commandList.removeElement(toRemove);
     }

     public void execute() 
     { 
		Command nextCommand;

        System.out.println("Automated playback of stored commmands...");

		for (int i=0; i < commandList.size(); i++)
		{
			nextCommand = (Command) commandList.elementAt(i);
			nextCommand.execute();
        }
        System.out.println("Finished automated playback of stored commmands.");
     }
}

⌨️ 快捷键说明

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