-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
62 lines (51 loc) · 1.54 KB
/
main.cpp
File metadata and controls
62 lines (51 loc) · 1.54 KB
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
/*Central management of collections with various behaviors*/
#include "SolarSystem.hpp"
int main() {
try {
SolarSystem<int>
system; // Generics: int type, local instance (no global state)
system.addPlanet();
system.addPlanet();
system.addPlanet();
system.planetCount();
system.deleteElement(0);
system.pushToPlanet(0, 10);
system.pushToPlanet(0, 20);
system.pushToPlanet(0, 30);
system.pushToPlanet(1, 10);
system.pushToPlanet(1, 20);
system.pushToPlanet(1, 30);
system.pushToPlanet(2, 10);
system.pushToPlanet(2, 20);
system.pushToPlanet(2, 30);
system.elementCount();
system.travelPlanet();
system.deleteElement(0);
system.deleteElement(1);
system.deleteElement(2);
system.travelPlanet();
system.elementCount();
system.blackHole(1); // Destroy second planet
system.travelPlanet();
system.planetCount();
system.gravityPull(15); // Remove elements < 15
system.travelPlanet();
system.elementCount();
system.supernova(); // Destroy everything
system.travelPlanet();
system.planetCount();
} catch (const out_of_range &e) {
cerr << "[Out of Range Error] " << e.what() << endl;
return 1;
} catch (const underflow_error &e) {
cerr << "[Underflow Error] " << e.what() << endl;
return 2;
} catch (const invalid_argument &e) {
cerr << "[Invalid Argument] " << e.what() << endl;
return 3;
} catch (const exception &e) {
cerr << "[Unexpected Error] " << e.what() << endl;
return 4;
}
return 0;
}