Advertisement
Broatlas

SwitchEntry.java

Apr 19th, 2016
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. /************************************************************************
  2.  *
  3.  *Class:  SwitchEntry
  4.  *Author :Robert Taracha CST8130 - 2016
  5.  *purpose:  This class handles the array objects of a layer 2 switch table
  6.  *data members:  seAddress: MACAddress - holds address of entry
  7.  *           port: String - holds port information
  8.  *methods:  addEntry (MACAddress, String) - initializes object with parameters
  9.  *   isEqual(MACAddress):boolean - compares seAddress in object to parameter
  10.  *   getAddress(): MACAddress
  11.  *   getPort():String
  12.  *
  13.  */
  14. public class SwitchEntry {
  15.     private MACAddress seAddress;
  16.     private String port;
  17.    
  18.     public SwitchEntry () {
  19.         seAddress = new MACAddress();
  20.         port = "no";
  21.     }
  22.    
  23.     public SwitchEntry (MACAddress address, String port) {
  24.         seAddress = new MACAddress(address);
  25.         this.port = new String(port);
  26.     }
  27.    
  28.     // note to students...this is not actually used in the assignment - I wrote it to demo that it could be written
  29.     public boolean isEqual (MACAddress rhs) {
  30.         return seAddress.isEqual(rhs);
  31.     }
  32.    
  33.     public MACAddress getAddress() {
  34.         return seAddress;
  35.     }
  36.    
  37.     public MACAddress getSeAddress() {
  38.         return seAddress;
  39.     }
  40.  
  41.     public void setSeAddress(MACAddress seAddress) {
  42.         this.seAddress = seAddress;
  43.     }
  44.  
  45.     public void setPort(String port) {
  46.         this.port = port;
  47.     }
  48.  
  49.     public String getPort() {
  50.         return port;
  51.     }
  52.    
  53.     public String toString() {
  54.         return "address: " + seAddress + " port " + port;
  55.     }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement