Question
(java help ) In Project 1 we laid the foundation of what will become a simple network packet transmission simulation. This project will build upon
(java help ) In Project 1 we laid the foundation of what will become a simple network packet transmission simulation. This project will build upon this foundation, utilizing a queue structure to store atomic packets of data which will travel across the network. The advantage of a queue is that, once a routing system is constructed in Project 3, latency will naturally be minimized as packets are essentially prioritized by wait time. Please construct the following class, defined in a file named Packet.java. Packet This class should contain the following private variables. You should define public functions which get and set the values of these variables. An integer called targetID An integer called sourceID A String called data Network Object This class (from Project 1) should be modified to contain a private queue variable called packets. How you decide to implement the queue is up to you, so long as it functions according to the normal FIFO expectations of a queue and stores references to packet objects. We will use this queue of packets in Project 3 to begin routing packets between network objects and begin to simulate communication between network objects. project 1 :class NetworkObject{ private int objectld; private NetworkObject nextNetworkObject; public NetworkObject(int x){ objectld=x; } public int getObjectld(){ return objectld; } public NetworkObject getNextNetworkObject(){ return nextNetworkObject; } public void setNextNetworkObject(NetworkObject x){ nextNetworkObject = x; }} public class PROJECT1CSC220 { public static void main(String[] args){ NetworkObject p; NetworkObject n1 = new NetworkObject(1); NetworkObject n2 = new NetworkObject(2); NetworkObject n3 = new NetworkObject(3); n3.setNextNetworkObject(null); n1.setNextNetworkObject(n2); n2.setNextNetworkObject(n3); p = n1; while (p != null){ System.out.println(p.getObjectld()); p = p.getNextNetworkObject(); } }}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started