-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
53 lines (40 loc) · 1.34 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
#include <iostream>
#include "libs.h"
using namespace HouseExchanger;
int main() {
//* Setup
// Clear screen
std::system("cls");
// Get singleton system object to manage all the data
// This is the only way to access the system object
// and avoid system object being created multiple times
System *system = System::getInstance();
// By default, the system is not initialized.
// Therefore, we have to initialize it to load all
// data before the user can interact with the system.
bool initialized = system->initialize();
// Throw an exception if the system
// failed to initialize.
if (!initialized) {
throw std::runtime_error("System failed to initialize correctly.");
return 1;
}
// System is now initialized.
// Display welcome message.
displayWelcomeMsg();
//* Main loop
// The main loop is a while loop that runs until the user quits.
mainLoop();
// Shutdown the system, which will automatically
// save all the system resources internally.
bool shutdownSuccessful = system->shutdown();
//* Cleanup
delete system;
// Throw an exception if the system
// failed to shutdown properly.
if (!shutdownSuccessful) {
throw std::runtime_error("System failed to shutdown correctly.");
return 2;
}
return 0;
}