command.java

来自「The Java Network Simulator is a Java imp」· Java 代码 · 共 59 行

JAVA
59
字号
package jns.command;


/**
 Command is a very important class in JNS because it represents the commands
 that the simulator is supposed to execute at a specific time.<br>
 You have to subclass command to make use of it. You can then use it to
 schedule a call to your class' foobar() function after x seconds.
 */
public abstract class Command
{

    String m_name;         // Name of the command (be artistic)
    double m_time;         // The time at which the command should be executed

    /**
     Create a new command class with a specific name to execute at some
     specific time.
     @param name name of the command
     @param time the time at which to execute the command
     */
    public Command(String name, double time)
    {
        m_name = name;
        m_time = time;
    }


    /**
     Return the command's execution time.
     */
    public double getTime()
    {
        return m_time;
    }

    /**
     Return the command's name.
     */
    public String getName()
    {
        return m_name;
    }

    /**
     Debugging output, print's the command's name.
     */
    public void dump()
    {
        System.out.println(m_name + ": " + m_time);
    }

    /**
     The execution function. Has to be overridden by subclasses.
     */
    public abstract void execute();

}

⌨️ 快捷键说明

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