-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolarSystem.h
More file actions
53 lines (46 loc) · 987 Bytes
/
SolarSystem.h
File metadata and controls
53 lines (46 loc) · 987 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <math.h>
using namespace std;
class SolarSystem{
public:
double mercury, venus, earth, mars, jupiter, neptune;
double asteroid;
double moon;
double distanceFromSun;
double setDistance(int s)
{return distanceFromSun=s;}
};
class Planet : public SolarSystem{
public:
double mass;
double radius;
Planet() {}
Planet (double r) : radius(r) {}
double volume(double r)
{return (4.0/3.0)*M_PI*pow(r, 3);}
friend Planet duplicate (const Planet&);
};
Planet duplicate (const Planet& param)
{
Planet pla;
pla.radius = param.radius*2;
return pla;
}
template <class T>
class Interaction{
T planets[2];
public:
Interaction (T first, T second)
{
planets[0]=first;
planets[1]=second;
}
T getMaxDistance ();
};
template <class T>
T Interaction<T>::getMaxDistance ()
{
T retval;
retval = planets[0]>planets[1]? planets[0] : planets[1];
return retval;
}