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

📄 routerlocationentry.java

📁 使用Java语言编写模拟路由器程序
💻 JAVA
字号:
/* File: RouterLocationEntry.java * * Author: Venkata Sastry Malladi * * This file contains the code for the class RouterLocationEntry, * which represents and entry in the Router Location File * * Preferred Editor: emacs */import java.net.*;class RouterLocationEntry {	// the IP address of the router	InetAddress ip;	// the port used to listen to the commands from the Command program	int commandPort;	// the port used to listen to the distance vector packets sent by the other	// routers	int routerPort;	// the id of the router	int routerId;	/*	 * Constructor	 * 	 * Use: To initialize the entry	 * 	 * @i: the IP address of the router @c: the command port @r: the router port	 * @id: the router id	 */	public RouterLocationEntry(InetAddress i, int c, int r, int id) {		ip = i;		commandPort = c;		routerPort = r;		routerId = id;	}	/*	 * Method Name: getIp()	 * 	 * Use: To return the IP address of this entry/router	 */	InetAddress getIp() {		return ip;	}	/*	 * Method Name: getCommandPort	 * 	 * Use: To return the command port of this entry/router	 */	int getCommandPort() {		return commandPort;	}	/*	 * Method Name: getRouterPort	 * 	 * Use: To return the router port of this entry/router	 */	int getRouterPort() {		return routerPort;	}	/*	 * Method Name: getRouterId	 * 	 * Use: To return the id of this entry/router	 */	int getRouterId() {		return routerId;	}	/*	 * Method Name: equals	 * 	 * @rle: another RouterLocationEntry object	 * 	 * Use: Used to find out whether there are any duplicate entries in the	 * table	 */	boolean equals(RouterLocationEntry rle) {		return (rle.routerId == routerId);	}	/*	 * Method Name: toString	 * 	 * Use: To get a textual representation of the entry	 */	public String toString() {		return ("(" + ip + "," + commandPort + "," + routerPort + ","				+ routerId + ")");	}}

⌨️ 快捷键说明

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