NEED URGENT HELP! PLEASE HELP!

Create a program that contains one class that has all the planets and so you can add more or delete. The planets should have the surface area, and the density of each planet where g is acceleration due to gravity.

it needs to have a menu that looks like this:
1. Add
2. Delete
3. Sort
4. Find
5. Display All
6. Exit

PLEASE HELP IM LOST
Is this for homework?

Create a class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  class SolarSystem
   {
        public:
        SolarSystem();
        add(double, double); //adds a planet
        remove(double, double); //removes a planet
        sort(); //sort function
        find(double, double); // finds a planet
        display(); //display all the link list
        private:
           class Planet //link list of planets
           {
             public:
             double surface_area;
             double density;
             Planet * next; //points to the next planet in line
            };
         Planet* firstplanet; //pointer to first planet
};


try that...?
Last edited on
Very very helpful, man! thanks so much!
you can also separate them in tow class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class SolarSystem
   {
        public:
        SolarSystem();
        add(Planet* pal); //adds a planet
        remove(Planet* pal); //removes a planet
        sort(); //sort function
        find(Planet* pal); // finds a planet
        display(); //display all the link list
        private:
			Planet* firstplanet; //pointer to first planet
        
};

   class Planet //link list of planets
           {
             private:
								double surface_area;
								double density;

				public:
					Planet() { } 
					Planet( double sa , double den ) : surface_area( sa ) , density( den )  { } 
					setSurfaceArea( double  sa ) ; 
					setDensity( double den);
					double get SurfaceArea( ) ; 
					double getDensity() ; 				
            };
         
Topic archived. No new replies allowed.