-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMastermind.cpp
More file actions
54 lines (40 loc) · 904 Bytes
/
Mastermind.cpp
File metadata and controls
54 lines (40 loc) · 904 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Mastermind.h"
using std::cout;
using std::cin;
using std::vector;
using std::string;
void clear_int_stream() {
if (cin.fail()) {
cin.clear();
for (char ch; cin >> ch;)
return;
}
}
int get_int() {
int input = 0;
while (true) {
if (cin >> input) return input;
clear_int_stream();
return -1;
}
}
int get_int(int low, int high) {
while (true) {
int n = get_int();
if (low <= n && n <= high) return n;
else {cin.ignore(1000, '\n'); cout << "\nKeine Gültige Eingabe!\n\n"; return -1;}
}
}
/*/
void Mastermind::chooseMode()
{
int select;
cout << "Wählen Sie den Spielmodus:\n(1) Zahlencode\n(2) Buchstabencode\n";
select = get_int(1,2);
switch (select)
{
case 1: case 2: play(select); break;
case 3: return;
}
}
*/