routerlocationentry.java
来自「使用Java语言编写模拟路由器程序」· Java 代码 · 共 99 行
JAVA
99 行
/* 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 + =
减小字号Ctrl + -
显示快捷键?