packet.java
来自「使用Java语言编写模拟路由器程序」· Java 代码 · 共 49 行
JAVA
49 行
/* File: Packet.java * * This file contains the code for the class Packet, * which represents a Distance Vector packet exchanged * between the routers. It is just and abstraction over * the Distance Vector to include the ID of the router * that is sending the Distance Vector */import java.util.*;import java.io.*;class Packet implements Serializable { // The ID of the router sending the Distance Vector int routerId; // The Distance Vector HashMap dv; /* * Constructor * * @id: The id of the router @dv: The Distance Vector * * Use: To initialize the Packet */ public Packet(int id, HashMap d) { routerId = id; dv = d; } /* * Method Name: getRouterId * * Use: To get the ID of the router that sent the packet */ int getRouterId() { return routerId; } /* * Method Name: getDV * * Use: To get the Distance Vector contained in the packet */ HashMap getDV() { return dv; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?