Question
C++ Project. Looks long because i included the previous questions and codes we used. I am attaching the pictures of Project 1 and 2, and
C++ Project. Looks long because i included the previous questions and codes we used. I am attaching the pictures of Project 1 and 2, and the answer( code) we used, which we already finished. I need help for Project 3 only!! others are for reference. I also attach the part of the code to use in Project 3, which was given to us by the professor. Pls help! Thanks!
Code used for Proj 1:
#include
using namespace std;
class NetworkObject
//beginning Network Object class definition
{
public:
//Constructor
NetworkObject(int objId): objectId(objId){
}
//Parameterized constructor
NetworkObject();
//returns objectId
int getObjectId(){
return objectId;
}
private:
//private member
int objectId;
};
//server class constructor is called from networkobject class parameterized constructor
class Server : public NetworkObject
{
public:
Server(int objId): NetworkObject(objId){}
};
int main()
{
//declare 6 NetworkObjects with id 4,8,16, 32, 64, 128.
NetworkObject at[6] = {{4}, {8}, {16}, {32}, {64}, {128}};
for(int i=0; i
{
//prints the object IDs of the network objects
cout
}
}
Code Used for Project 2:
#include #include #include #include using namespace std; class Packet{ private: //private member int targetID; int sourceID; string data_Network_Object; public://constructor void setTargetID(int t);// set method for targetid void setSOurceID(int s);// set method for sourceid void setDateNetworkObject(string d); // set method for data int getTargetID(); // get method for targetid
int getSourceID(); // set method for sourceid
string getDatanetworkObject(); // get method for data
};
//constructor to initialize member variables
void Packet::setTargetID(int t){ //set method for TargetID targetID=t; }
void Packet::setSOurceID(int s){ //set method for sourceID sourceID=s; } void Packet::setDateNetworkObject(string d){ //set method for data data_Network_Object=d; } int Packet::getTargetID(){ //get method for targetID return targetID; } int Packet::getSourceID(){ //get method for sourceID return sourceID; } string Packet::getDatanetworkObject(){ //get method for data return data_Network_Object; }
class NetworkObject{ //beginning Network Object class definition
public://Constructor
NetworkObject(int objectId){this->objectId = objectId;}//Parameterized constructor NetworkObject(){}//push packet into the queue int getObjectId(){return objectId;} queue getPacketQueue(){ return packets;}//get packet queue private://private member
int objectId; queue packets;//packets variable to store the packets in an queue };
int main() { //creating packets NetworkObject objects[10]; //declare 10 network objects for(int i = 0; i
}
stringstream ss;
queue q=objects[0].getPacketQueue();
for(int i=1;isetTargetID(i); p1->setSOurceID(i+5); int val=objects[0].getObjectId(); ss setDateNetworkObject(ss.str()); q.push(p1); }
//prints the object IDs of the network objects and packet information
cout0){ coutgetTargetID()getSourceID()
return 0;
}
^^^^^ I need help on this project 3 ^^^
Teacher gave the part of the code that helps in doing this project which is below:
One extra week to work for Project 3 ( i couldnt finish copying it from the slides, i will add more if i get the rest of it.)
class Network Object{
Public:
NetworkObject getNextNetworkObject (){
return nextNetworkObject;
}
void setNextNetworkObject(NetWorkObject obj){
next = obj;
}
Private:
double prob = 0.3;
NetworkObject* next;
};
update(){
Packets* p = get Packets(10);
for (int i = 0; i
double x = rad();
if (x)
Pls help. Any questions, comment. Thanks
Project 1 Due: February 14, 2018 at 11:55 PM 1 of 2 This project lays the foundation for a series of programs which address various problems in computer networking Before dving into the complex problems, it important to tuld experanc? with th?? programming language and techniques wu wil use to solve them. As demonstrated in class, the syntax of C+is very similar to Java o estabishing a loval of comfort while exercising problam-solving skils is emphasized here rathar than minutiae of the language. Those detais wil be incorporated into later projects through appication Keep in mind that there are many resources to leam the syntactic detais of C++. The requred and recommended textbooks isted in the Sylabus and the class slides are good resouroes. Using the intemet to firnd adddonal resources is enoouraged, however the policy on plagiarism is dear and wry strict. Do not copy and submit code which i not your own Problem Description This phase of the project wil establish two classes Their specific implamentation detais are fexible, but they should meet the following requirements NatworkObject This class called NetworkObject defines the abstract properties of an element of our network. Addtional capabilities wil be added to classes derived fron this base class in order to power futire projacts The class should contain at least the following private variables: int objectld The class should contain at least the following public methods Constructor which sets the objetild when an object is created int getobjectido Returns th? objectid variable Server This class is a "dummy" derived class to which we will add complexity in future projects. The class should inherit from the NetworkObject class (we will go into detail about inheritance in the 2/10 lecture). For now, it requires no additional functionality beyond a constructor method Other Requirements In your main function, choose a way to store a number of NetworkObject objects This may be an array, a vector, a linked list, etc, it is your design choice at this stage The main function should then instantiate some objects and then print their objectld's using the functions and classes created above Project 1 Due: February 14, 2018 at 11:55 PM 1 of 2 This project lays the foundation for a series of programs which address various problems in computer networking Before dving into the complex problems, it important to tuld experanc? with th?? programming language and techniques wu wil use to solve them. As demonstrated in class, the syntax of C+is very similar to Java o estabishing a loval of comfort while exercising problam-solving skils is emphasized here rathar than minutiae of the language. Those detais wil be incorporated into later projects through appication Keep in mind that there are many resources to leam the syntactic detais of C++. The requred and recommended textbooks isted in the Sylabus and the class slides are good resouroes. Using the intemet to firnd adddonal resources is enoouraged, however the policy on plagiarism is dear and wry strict. Do not copy and submit code which i not your own Problem Description This phase of the project wil establish two classes Their specific implamentation detais are fexible, but they should meet the following requirements NatworkObject This class called NetworkObject defines the abstract properties of an element of our network. Addtional capabilities wil be added to classes derived fron this base class in order to power futire projacts The class should contain at least the following private variables: int objectld The class should contain at least the following public methods Constructor which sets the objetild when an object is created int getobjectido Returns th? objectid variable Server This class is a "dummy" derived class to which we will add complexity in future projects. The class should inherit from the NetworkObject class (we will go into detail about inheritance in the 2/10 lecture). For now, it requires no additional functionality beyond a constructor method Other Requirements In your main function, choose a way to store a number of NetworkObject objects This may be an array, a vector, a linked list, etc, it is your design choice at this stage The main function should then instantiate some objects and then print their objectld's using the functions and classes created aboveStep 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