-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
106 lines (95 loc) · 1.72 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
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <iostream>
#include "MineSweeper.h"
using namespace std;
void rules()
{
system("cls");
cout << "The rules in Minesweeper are simple:" << endl << endl
<< "Uncover a mine, and the game ends" << endl << endl
<< "Uncover an empty square, and you keep playing" << endl << endl
<< "Uncover a number, and it tells you how many mines" << endl
<< "lay hidden in the eight surrounding squares information" << endl
<< "you use to deduce which nearby squares are safe to uncover." << endl << endl;
system("pause");
system("cls");
}
bool keepPlay()
{
int num;
while (true){
cout << "1. Play Game" << endl
<< "2. Rules" << endl
<< "3. Quit" << endl
<< "Enter: ";
cin >> num;
cout << endl;
if (num == 1)
{
return true;
}
else if (num == 2)
{
rules();
}
else if (num == 3)
{
return false;
}
else
{
cout << "Invalid choice" << endl << endl;
system("pause");
system("cls");
}
}
}
difficulty select()
{
char in;
while (true)
{
system("cls");
cout << "Beginner [10x10 with 10 mines]: b" << endl
<< "Intermediate [16x16 with 40 mines]: i" << endl
<< "Expert [16x32 with 100 mines]: e" << endl
<< endl
<< "Enter a difficulty: " << endl;
cin >> in;
cout << endl;
if (in == 'b')
{
return b;
}
else if (in == 'i')
{
return i;
}
else if (in == 'e')
{
return e;
}
else
{
cout << "Invalid choice" << endl << endl;
system("pause");
system("cls");
}
}
}
int main()
{
try{
while (keepPlay()){
MineSweeper game(select());
while (game.turn());
}
system("cls");
cout << "Thanks for Playing!" << endl << endl;
}
catch (Exception &e)
{
cout << e << endl;
}
system("pause");
return 0;
}