-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbunko.cpp
More file actions
74 lines (55 loc) · 1.48 KB
/
bunko.cpp
File metadata and controls
74 lines (55 loc) · 1.48 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <limits>
#include <iterator>
#include "player.h"
using namespace std;
void createPlayers (int numPlayers, Player players[]) {
int i = 0;
string playerName = " ";
while(i < numPlayers) {
cout << "Who is playing?" << endl;
cin >> playerName;
players[i].setName(playerName);
players[i].setScore(0);
i = i + 1;
}
} // createPlayers
void playBunko() {
Player * players = new Player[4];
int numPlayers = 0;
while (numPlayers != 2 || numPlayers != 4) {
cout << "How many players? (2/4)" << endl;
cin >> numPlayers;
if (numPlayers == 2 || numPlayers == 4) {
createPlayers(numPlayers, players);
} else {
cout << "Please enter either 2 or 4 players." << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
cout << "Round " << endl;
} // playBunko
int main() {
char play = 'y';
cout << "Welcome to Bunko!" << endl;
while (1) {
cout << "Would you like to play a match? (y/n)" << endl;
cin >> play;
switch(play) {
case 'y':
playBunko();
break;
case 'n':
cout << "Thanks for playing!" << endl;
return 0;
break;
default:
cout << "Please select y or n to play or quit." << endl;
}
}
return 0;
}