Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ ONLY Part 1: Planet Class Parts 1 and 2 of this recitation activity have a shared main file SolarSystem_main.cpp, provided to you on Moodle.

C++ ONLY

Part 1: Planet Class Parts 1 and 2 of this recitation activity have a shared main file SolarSystem_main.cpp, provided to you on

Moodle.

The class you will implement is called Planet . This time we have given you the class file planet.cpp . It is your job to create the header file for the planet class. Create the file planet.h in CodeBlocks in the same directory as the main file. The planet class has two constructors, a default constructor (which takes no arguments) and a constructor that takes two arguments. One argument should be the name of the planet and the radius of the planet (in km). It should also have getters and setters for the class attributes.

Part 2: Planet Class The next class you will implement is called solarSystem . The solarSystem .h file is provided on moodle,

and you will create your class file solarSystem.cpp .

There are four private attributes in this class: maxNumPlanets (the max number of planets in this solar system) , systemName (the name of the solar system) , numPlanets (how many planets are in this solar system) and systemPlanets (an array of planets in this solar system) .

There should also be one constructor, a destructor, and five methods to create for the solarSystem class. Two of the five methods are getters for the class attributes systemName and numPlanets . addPlanet(string, float) should add a new planet into the solar system. getPlanet(int) should return the the planet object of the index indicated by the argument. Finally, you will have to add a member function,

radiusDifference(Planet, Planet), that calculates the difference in radius between two planets (read the comments in solarSystem_main.cpp for more information) .

Once you have implemented the header file for the planet class, you will need to modify your main to test

your classes. In solarSystem_main.cpp , you will have to ask the user for names and the radius of five

new planets you want to add to the solar system, and print out the difference in radius between every two

planets in the system. Find a smart logic to compute all the differences as there are

C (5, 2) = 5! = 10 possible combinations and you do not want to hard code all of them. Additional 2!(52)!

information is found in the source files. image text in transcribed

solarSystem.himage text in transcribedimage text in transcribed

planet.cpp include "planet,h" planet::planet()I planet: :planet(string planetName, float planetRadius) name = planetName; radius = planetRadius; planet: planet) //letting compiler handle deconstruction of the class void planet::setName (string planetName) name planetName ; string planet: :getName() return name; void planet::setRadius (float planetRadius){ radius = planetRadius; float planet::getRadius ) return radius

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3. Did you seek anyones advice?

Answered: 1 week ago

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago