diff --git a/examples/src/OpenDis7Examples/ExampleSimulation.java b/examples/src/OpenDis7Examples/ExampleSimulation.java index f7981d47aefa6f223026e7dbed23ae310efb89cc..5e3d2bb62be4d52f5ce28ef05f7a5cfd94831d7f 100644 --- a/examples/src/OpenDis7Examples/ExampleSimulation.java +++ b/examples/src/OpenDis7Examples/ExampleSimulation.java @@ -21,15 +21,68 @@ public class ExampleSimulation DisThreadedNetworkInterface.PduListener pduListener; Pdu receivedPdu; - String networkAddress = "239.1.2.3"; - int networkPort = 3000; + private String networkAddress = "239.1.2.3"; + 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 */ public void setUpNetworkInterface() { - disNetworkInterface = new DisThreadedNetworkInterface(networkAddress, networkPort); + disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); System.out.println("Network confirmation: address=" + disNetworkInterface.getMcastGroup() + " port=" + disNetworkInterface.getDisPort()); pduListener = new DisThreadedNetworkInterface.PduListener() @@ -102,6 +155,10 @@ public class ExampleSimulation public static void main(String[] args) { // initial execution: can handle args array of initialization arguments here + if (args.length == 2) + { + + } ExampleSimulation thisProgram = new ExampleSimulation(); // creates instance