-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (50 loc) · 1.46 KB
/
main.cpp
File metadata and controls
56 lines (50 loc) · 1.46 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
#include "BaseException.h"
#include "Casino.h"
#include "CasinoData.h"
#include "CasinoRepository.h"
#include <iostream>
#include <string>
int main()
{
try
{
CasinoRepository repository("casino_data.txt");
CasinoData data;
if (repository.load(data))
{
std::cout << "Previous data found!" << std::endl;
std::cout << "Welcome back, " << data.playerName << "! your balance is: " << data.playerBalance << std::endl;
}
else
{
std::cout << "no previous data found. starting a new game!" << std::endl;
std::cout << "enter your name: ";
std::cin >> data.playerName;
std::cout << "enter your starting balance: ";
std::cin >> data.playerBalance;
data.budget = 5000;
if (repository.save(data))
{
std::cout << "Initial game data saved successfully!" << std::endl;
}
else
{
std::cout << "Failed to save initial game data." << std::endl;
}
}
Casino casino(data, repository);
casino.addGame("Roulette");
casino.addGame("Blackjack");
casino.run();
return 0;
}
catch (const BaseException &exception)
{
std::cout << exception.what() << std::endl;
}
catch (const std::exception &exception)
{
std::cout << exception.what() << std::endl;
}
return 1;
}