Hey guys, need some help in figuring how to write this program. The program should have a menu with the following:
1)Add planet (prompt for name, radius, mass)
2)Delete planet (prompt for name)
3)Find planet (display name, radius, mass, surface area, volume, and gravity at surface)
4)List all planets (using vectors)
5)Sort by name (alphabetical)
6)Quit
I think I got how to put the list to show up with the following code but need some help with how to make classes and vectors.
quick question, should I put all the variables (mass, density, etc) that I want to display in private or public (under class Planet). How do I make it so that when I enter Earth, it displays all the properties for that planet?
looking okay. now you need to read up on some vector methods like:
1. push_back() - for adding a planet to your collection
2. erase() to remove one.
3. also about finding the correct planet in your collection (so you delete the right one).
also after line 73 you need to create a planet object, assign your name, radius and mass into it (possibly via the constructor?), then push this onto your vector (using push_back() ).
delete line 11, move line 10 into your class as a member variable.
All of your methods deal with the collection of planets, rather than a single planet these should NOT be in the planet class.