I need help with a C++ program. Here are the instructions: Keywords: has object,
ID: 3669726 • Letter: I
Question
I need help with a C++ program. Here are the instructions:
Keywords: has object, passing object.
1) Implement a class named StarWars; Class StarWars has a class named World; (2 points)
2) The object starWarsOBJ created the Class Moon as a tool that Darth Vader uses to control the Class World; Therefore, having the object worldOBJ within your starWarsOBJ, pass the object moonOBJ as an argument to the worldOBJ;(2 points)
3) The moonOBJ has a huge tower that is represented as the struct data_tower tower comprised of: int total_antennas, float *sending_signal, string message. (2 points)
4) Create the method Input asking 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; (2 points)
5) Run a simulation showing for each hour the sending_signal[total_antennas], is sending the string message that is printed on worldOBJ the 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 time in the simulator and which antenna is sending the signal. (2 points)
Explanation / 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
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.