In: Computer Science
Create a program with the features: NEEDED IN C++.
Keywords: has object, passing object
1) Implement a classnamed StarWars; Class StarWarshas a classnamed World;
2) The object starWarsOBJcreated the Class Moonas a tool that Darth Vader uses to control the Class World; Therefore, having the object worldOBJwithin your starWarsOBJ, pass the object moonOBJ as an argument to the worldOBJ;
3) The moonOBJhas a huge tower that is represented as the struct data_tower towercomprised of: int total_antennas,float *sending_signal, string message.
4) Create the method Inputasking the user what is the value for total_antennas, and then make the dynamic allocation of your array of float sending_signal[total_antennas], using the commands new and delete accordingly;
5) Run a simulation showing for each hour the sending_signal[total_antennas], is sending the string messagethat is printed on worldOBJthe following phrase, as ordered by Darth Vader: “... Darth Vader is the Great!...”. This message is repeated for each of the sending_signal[total_antennas], i.e. if you have 10 antennas, the message will be repeated 10 antennas x 24 hours a day; when printing the message, inform also what is the current time step in the simulator and which antenna is sending the signal.
ANSWER :
Program in C++
#include<iostream>
#include<string>
using namespace std;
class Moon //Here is the Moon class having struct
data_tower- Part 3
{
public:
struct data_tower
{
int
total_antennas;
float
*sending_signal;
string
message;
};
data_tower tower1;
//variable of data_tower type
};
class StarWars //Here is the class StarWars Part 1
{
public:
class World //
Inner class World in StarWars class
{
public:
};
World worldOBJ(Moon
moonOBJ); // Passing object of Moon class as argument Part
2
};
int main()
{
int totalAntennas;
Moon moonOBJ;
cout<<"Enter the value of
total_antennas"<<endl; //taking total_antennas as
input from user Part 4
cin>>totalAntennas;
moonOBJ.tower1.total_antennas =
totalAntennas;
moonOBJ.tower1.sending_signal = new
float[moonOBJ.tower1.total_antennas]; // dynamically
allocating float array
}
( PLEASE VOTE FOR THIS ANSWER )
I THINK IT WILL BE USEFULL TO YOU .......
PLZZZZ COMMENT IF YOU HAVE ANY PROBLEM I WILL TRY TO SOLVE IT .....
THANK YOU ...............