-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbridge.cpp
51 lines (38 loc) · 960 Bytes
/
bridge.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
/// File: bridge.cpp
/// Creates a deck of cards, shuffles them and displays them.
#include <iostream>
#include <iomanip>
#include <fstream>
#include "game.h"
const int NUM_DEALS = 4;
using namespace std;
int main(int argc, char *argv[]) {
Game game;
ifstream infile;
bool fromFile = false;
if (argc == 2) {
// open the file and check it exists
infile.open(argv[1]);
if (infile.fail()) {
cerr << "Error: Could not find file" << endl;
return 1;
}
fromFile = true;
}
for (int deal = 0; deal < NUM_DEALS; deal++) {
game.setup(fromFile);
if (fromFile) {
infile >> game;
}
game.deal();
game.auction();
cout << game << endl;
cout << endl << "==============================================================" << endl << endl;
game.nextDealer();
}
// close the file
if (argc ==2) {
infile.close();
}
return 0;
}