Question: (C++) Create a class Planet, with separate interface file (Planet.h) and implementation file (Planet.cpp), comprised of the following attributes: Data members (private): string: planetName -

(C++) Create a class Planet, with separate interface file (Planet.h) and implementation file (Planet.cpp), comprised of the following attributes:

Data members (private):

string: planetName - Name of the planet

double: planetRadius - Radius of the planet

Member functions (public):

Default constructor - Sets planetName to empty string, and planetRadius to 0.0

Parameterized constructor - Takes a string and double initializing planetName and planetRadius, in this order

getName() - Returns planetName as a string

setName(string) - (void) Assigns planetName the value of the input string

getRadius() - Returns planetRadius as a double

setRadius(double) - (void) Assigns planetRadius the value of the input double

getVolume() - Calculates and returns the volume of the planet as a double

Please create 3 files: Planet.h, Planet.cpp, and driverPlanet.cpp (a file just for testing the member functions)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!