command.java

来自「这是一个用Java编写的路由器模拟程序。可以利用计算机模拟路由器实现路由表的生成」· Java 代码 · 共 53 行

JAVA
53
字号
class Command
{
	String cmd;
	Integer ID;
	public Command(Integer ID,String cmd)
	{
		this.cmd=cmd;
		this.ID=ID;
	}
	/*
	public void T(Integer ID)//输出路由表
	{
		Router r=allRouter.get(ID);//返回一个路由器对象
		System.out.println("The Router "+ID+"'s routingtable is :");
		System.out.println(r.RoutingTable);
	}
	public void N(Integer ID)//输出邻居列表
	{
		Router r=allRouter.get(ID);
		System.out.println("The Router "+ID+"'s neighbor is :");
		Interator it=r.neighbors.interator();
		while(it.hasNext())
		{
			System.out.println(it.next());
		}
	}
	*/
	public void D(Integer ID)//关闭路由器,从活动列表中删除这个路由器,相应的,邻居路由器从活动列表中获得信息
	{
		if(activeRouter.contains(ID))
		{
			activeRouter.remove(ID);
		}
		else
		{
			System.out.println("The ID of the router you want to delete is invalid.");
		}
	}
	public void A(Integer ID)//启动路由器
	{
		if(IDS.contains(ID.toString()))	//IDS里面的类型是String类型
		{
			activeRouter.add(ID);
		}
		else
		{
			System.out.println("The ID of the router you want to activite is invalid.");
		}
	}
	
	//synchronized String executeCommand(String command)//要注意命令的格式,命令的格式是  order-ID

}

⌨️ 快捷键说明

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