Skip to content
Snippets Groups Projects
Commit fb4e4409 authored by brutzman's avatar brutzman
Browse files

Utility methods and constructors

parent 3bb9b902
No related branches found
No related tags found
No related merge requests found
...@@ -21,15 +21,68 @@ public class ExampleSimulation ...@@ -21,15 +21,68 @@ public class ExampleSimulation
DisThreadedNetworkInterface.PduListener pduListener; DisThreadedNetworkInterface.PduListener pduListener;
Pdu receivedPdu; Pdu receivedPdu;
String networkAddress = "239.1.2.3"; private String networkAddress = "239.1.2.3";
int networkPort = 3000; private int networkPort = 3000;
/**
* Constructor design goal: additional built-in initialization conveniences can go here
* to keep student efforts focused on the runSimulation() method.
*/
public ExampleSimulation()
{
// Under consideration.
}
/**
* Utility Constructor
* @param address network address to use
* @param port corresponding network port to use
*/
public ExampleSimulation(String address, int port)
{
setNetworkAddress(address);
setNetworkPort(port);
}
/**
* @return the networkAddress
*/
public String getNetworkAddress()
{
return networkAddress;
}
/**
* @param networkAddress the networkAddress to set
*/
public final void setNetworkAddress(String networkAddress)
{
this.networkAddress = networkAddress;
}
/**
* @return the networkPort
*/
public int getNetworkPort()
{
return networkPort;
}
/**
* @param networkPort the networkPort to set
*/
public final void setNetworkPort(int networkPort)
{
this.networkPort = networkPort;
}
/** /**
* Initialize network interface, choosing best available network interface * Initialize network interface, choosing best available network interface
*/ */
public void setUpNetworkInterface() public void setUpNetworkInterface()
{ {
disNetworkInterface = new DisThreadedNetworkInterface(networkAddress, networkPort); disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort());
System.out.println("Network confirmation: address=" + disNetworkInterface.getMcastGroup() + " port=" + disNetworkInterface.getDisPort()); System.out.println("Network confirmation: address=" + disNetworkInterface.getMcastGroup() + " port=" + disNetworkInterface.getDisPort());
pduListener = new DisThreadedNetworkInterface.PduListener() pduListener = new DisThreadedNetworkInterface.PduListener()
...@@ -102,6 +155,10 @@ public class ExampleSimulation ...@@ -102,6 +155,10 @@ public class ExampleSimulation
public static void main(String[] args) public static void main(String[] args)
{ {
// initial execution: can handle args array of initialization arguments here // initial execution: can handle args array of initialization arguments here
if (args.length == 2)
{
}
ExampleSimulation thisProgram = new ExampleSimulation(); // creates instance ExampleSimulation thisProgram = new ExampleSimulation(); // creates instance
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment