-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
107 lines (79 loc) · 3.63 KB
/
main.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "object.h"
#include "object.cpp"
//#include <windows.h>
int main() {
string menuChoice;
solarSystem* currentSystem = NULL;
listOfSystems* systemList = new listOfSystems;
initializeSystemList(systemList);
while(menuChoice != "quit"){
//Sleep( 500 );
cout << "\nWhat would you like to do?\n 1. Create a new Solar System\n 2. Add a new object to current System\n 3. View objects in current System\n 4. Change current System\n" <<endl;
cin >> menuChoice;
switch (atoi(menuChoice.c_str())) {
case 1:
{
string solarSystemName;
cout << "\nSolar System name: ";
cin >> solarSystemName;
solarSystem* newSolarSystem = createSolarSystem(systemList, solarSystemName);
currentSystem = newSolarSystem; //to hold the system the user is currently using
cout << "\nNew solar system created:\n\n";
cout << "Name: " << newSolarSystem->name << " \n";
cout << "Size: " << newSolarSystem->numberOfBodies << " bodies\n";
cout << "Total Mass: " << newSolarSystem->totalMass << " kg \n";
cout << "Center of Mass: " << newSolarSystem->centerOfMass << " meters \n\n";
break;
}
case 2:
{
if (currentSystem == NULL) {
cout << "\nYou don't have any solar systems!\n\n";
break;
}
float mass, radius, xPosition;
string name;
cout << "\nWhat is the name of your object? ";
cin >> name;
cout << "What is the radius of your object? ";
cin >> radius;
cout << "What is the mass of your object? ";
cin >> mass;
cout << "What is the x-position of your object? ";
cin >> xPosition;
celestialBody *newCelestialBody = createCelestialBody(mass, radius, xPosition, name);
addBodyToSystem(newCelestialBody, currentSystem);
cout << "\nObject added:\n\n" << newCelestialBody->name;
cout << "\nRadius: " << newCelestialBody->radius << " meters\n";
cout << "Mass: " << newCelestialBody->mass << " kg\n";
cout << "x-position: " << newCelestialBody->xPosition << " meters\n\n";
break;
}
case 3:
if (currentSystem == NULL) {
cout << "\nYou don't have any solar systems!\n\n";
break;
}
if (currentSystem->numberOfBodies == 0) {
cout << "\nYour system is empty!\n\n";
break;
}
solarSystemPrint(currentSystem);
break;
case 4:
if (currentSystem == NULL) {
cout << "\nYou don't have any solar systems!\n\n";
break;
}
cout << "\nChange to:" << endl;
currentSystem = selectSystem(systemList);
cout << "\nThe current system is now " << currentSystem->name << endl;
break;
default:
if (menuChoice != "quit")
cout << "\nNot a valid option!\n\n";
break;
}
}
cout << "Goodbye!";
}