-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrands.cpp
82 lines (74 loc) · 2.21 KB
/
brands.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
#include "brands.h"
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
/**
* Constructors for carBrands class. One chooses the players that will be in the game.
*/
carBrands::carBrands(){
}
/**
*the setPlayerChoice and getPlayerChoice functions allow each player to choose a brand
*/
void carBrands::setPlayers(string p1, string p2, string p3, string p4){
players[0] = p1;
players[1] = p2;
players[2] = p3;
players[3] = p4;
}
string carBrands::getPlayers(int i){
return players[i];
}
void carBrands::setPlayerOneChoice(){
cout << players[0] << ", name a brand." << endl;
cin >> playerOneChoice;
std::transform(playerOneChoice.begin(), playerOneChoice.end(), playerOneChoice.begin(), ::tolower);
}
string carBrands::getPlayerOneChoice(){
return playerOneChoice;
}
void carBrands::setPlayerTwoChoice(){
cout << players[1] << ", name a brand." << endl;
cin >> playerTwoChoice;
std::transform(playerTwoChoice.begin(), playerTwoChoice.end(), playerTwoChoice.begin(), ::tolower);
}
string carBrands::getPlayerTwoChoice(){
return playerTwoChoice;
}
void carBrands::setPlayerThreeChoice(){
cout << players[2] << ", name a brand." << endl;
cin >> playerThreeChoice;
std::transform(playerThreeChoice.begin(), playerThreeChoice.end(), playerThreeChoice.begin(), ::tolower);
}
string carBrands::getPlayerThreeChoice(){
return playerThreeChoice;
}
void carBrands::setPlayerFourChoice(){
cout << players[3] << ", name a brand." << endl;
cin >> playerFourChoice;
std::transform(playerFourChoice.begin(), playerFourChoice.end(), playerFourChoice.begin(), ::tolower);
}
string carBrands::getPlayerFourChoice(){
return playerFourChoice;
}
/**
* openBrands opens the file with the list of brand names and puts them into array brands to be used in the game.
*/
void carBrands::openBrands(string filename){
int index = 0;
string line;
ifstream file;
file.open(filename);
if (file.is_open()){
while (getline(file, line)){
brands[index] = line;
index++;
}
cout << "Loading...\nSuccess!" << endl;
file.close();
}
else{
cout << "Loading...\nUnable to open File";
}
}