Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C++ #include using namespace std; class Point { private: int x,y; public: Point (int a=0,int b=0); // initialize the x and y coordinates of

IN C++

#include

using namespace std;

class Point {

private:

int x,y;

public:

Point (int a=0,int b=0); // initialize the x and y coordinates of a Point

double Distance(Point &C); // calculates the distance between two locations, the value is in meters

void print(); // prints the x and y coordinates of a Point

void setData(int a, int b); // set the values of the x and y coordinates of a Point

};

Assume all functions of the class point are defined and implemented correctly. Read the comments to understand the usage of the function. You cannot modify the above class.

Create a class Rocket that has the following data attributes: coordinates, ID of type integer, speed of type integer. The coordinates represents the x and y location of the rocket, make use of class point. ID is a constant serial integer that is given values according to the following serial numbers 100, 200, 300, etc.

Do not separate class implementation

The class should have the following member functions:

1. A default constructor.

2. An initializer constructor to initialize all data members of a Rocket, do any necessary validations

3. A copy constructor.

4. Write setter and getter functions for speed data member.

5. A function bool Safe (Rocket& r) that returns true if the two Rocket objects are in safe distance from each other. Two Rockets are considered in safe distance not to hit each other if they are 100 meters or more far from each other.

6. A function double Distance (Rocket& r) that returns the distance between two Rocket objects. Note: you must use the Distance function in Point class

Assume all set and get member functions are provided and ready to use. Also assume you have two member functions to print the object details named Display() and a function named setCoordinates(Point &p) are provided and ready to use.

Write a main program that does the following:

Define an array of Rocket objects named ROCKETS of size 10. Let user input the data for these objects.

Count the number of Rockets in the array that are in safe distance from the first Rocket. Note you must use the Safe function you defined above.

Print all Rocket objects in the array that are within 5 meters range from the last Rocket in the array. Note: you must use the Distance function in Rocket class.

in c++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain why the systems approach is necessary to manage projects.

Answered: 1 week ago