-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardGameSimulator.cpp
More file actions
76 lines (55 loc) · 1.56 KB
/
Copy pathCardGameSimulator.cpp
File metadata and controls
76 lines (55 loc) · 1.56 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
75
#include "CardGameSimulator.h"
#include "StatisticsKeeper.h"
#include "Game.h"
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
CardGameSimulator::CardGameSimulator() : totalPlayers(0), totalRounds(0), numOfGames(0)
{
for (int i = 0; i < 4; i++)
losers[i] = 0;
}
void CardGameSimulator::get_user_input() // Takes and saves all user inputs
{
string numGames;
cout << "Enter name of Deck input file: ";
cin >> deckInput;
cout << "Enter name of Player input file: ";
cin >> playerInput;
cout << "Enter name of output file: ";
cin >> output;
cout << "Enter number of games to be played: ";
cin >> numGames;
numOfGames = stoi(numGames);
};
void CardGameSimulator::generateGames()
{
ofstream outputFile(output); // Create the file write to //**replaced output
keeper.setNumGames(numOfGames);
for (int i = 0; i < numOfGames ; i++)
{
outputFile << "GAME " << (i + 1) << endl;
Game game1(deckInput, &outputFile); // Initialize deck from user given file & pass it file to output the deck to
ifstream fin(playerInput);
if (fin && fin.is_open())
{
fin >> game1; // Read all of the player(s) information (amount, probabilities, etc)
game1.gamePlay();
}
keeper.accumulateRounds(game1.getRnd());
keeper.accumulatePlayers(game1.getNumPlayers());
keeper.addLoser(game1.getLoserType());
}
keeper.printStats(outputFile);
outputFile.close(); // Close file when done
}
int CardGameSimulator::getNumOfGames()
{
return numOfGames;
}
int CardGameSimulator::getTotalRounds()
{
return totalRounds;
}