-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (30 loc) · 969 Bytes
/
Copy pathmain.cpp
File metadata and controls
37 lines (30 loc) · 969 Bytes
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
#include "Game.h"
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
srand(static_cast<unsigned>(time(0)));
int choice;
do {
Game game;
cout << endl << "Íîâàÿ èãðà íà÷àëàñü ";
game.ShowBoard();
try {
cout << endl << "Ââåäèòå 1, ÷òîáû íà÷àòü èãðàòü, èëè ââåäèòå 0,÷òîáû âûéòè: ";
cin >> choice;
if (cin.fail() || choice < 0 || choice > 1) {
throw invalid_argument("Íåïðàâèëüíûé ââîä, ââåäèòå ëèáî 1 ëèáî 0");
}
if (choice == 0) {
break;
}
else if (choice == 1) {
game.play();
}
}
catch (invalid_argument& error) {
Game::clearInput();
cerr << endl << error.what() << endl;
}
} while (true);
return 0;
}