-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
93 lines (76 loc) · 2.58 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
//
// main.cpp
// SerpientesEscaleras
//
// Created by Rosa Guadalupe Paredes Juarez on 18/05/20.
// Copyright © 2020 Rosa Paredes. All rights reserved.
//
#include <iostream>
#include "MyGame.h"
#include "InvalidConfigurationException.h"
using namespace std;
int main(int argc, const char * argv[]) {
char params = 'N';
cout << "Do you want to give parameters (Y/N)?" << endl;
cin >> params;
try {
if(params == 'Y') {
int tiles;
int snakes;
int ladders;
int penalty;
int reward;
int players;
int turns;
char gameType;
cout << "Number of tiles:" << endl;
cin >> tiles;
if(tiles < 1) {
throw InvalidConfigurationException("tiles", tiles);
}
cout << "Number of snakes:" << endl;
cin >> snakes;
if(snakes < 0) {
throw InvalidConfigurationException("snakes", snakes);
}
cout << "Number of ladders:" << endl;
cin >> ladders;
if(ladders < 0) {
throw InvalidConfigurationException("ladders", ladders);
}
cout << "Amount of penalty:" << endl;
cin >> penalty;
if(penalty < 0) {
throw InvalidConfigurationException("penalty", penalty);
}
cout << "Amount of reward:" << endl;
cin >> reward;
if(reward < 0) {
throw InvalidConfigurationException("reward", reward);
}
cout << "Number of players:" << endl;
cin >> players;
if(players <= 0) {
throw InvalidConfigurationException("players", players);
}
cout << "Number of turns:" << endl;
cin >> turns;
if(turns <= 0) {
throw InvalidConfigurationException("turns", turns);
}
cout << "Game type (M/A):" << endl;
cin >> gameType;
MyGame g = MyGame(tiles, snakes, ladders, penalty, reward, players, turns, gameType);
g.start();
} else {
MyGame g;
//g.initialize();
g.start();
}
}
catch(InvalidConfigurationException &e) {
cout << e.what() << e.getName() <<" with value :"<< e.getValue() <<endl;
return 1;
}
return 0;
}