网络模拟器

源代码在线查看: command.java

软件大小: 1433 K
上传用户: szjunhui899
关键词: 网络 模拟
下载地址: 免注册下载 普通下载 VIP

相关代码

				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.
				 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();
				
				}
							

相关资源