-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
136 lines (126 loc) · 4.15 KB
/
main.cpp
File metadata and controls
136 lines (126 loc) · 4.15 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "linked_list.h"
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;
string option;
string option2;
int rosterNum;
unordered_map<string, string> map;
vector<List> playerInsert(){
cout << "welcome to the FantasyPool generator" << endl;
cout << "How many participants are there?" << endl;
int num;
cin >> num;
vector<List> fullList;
for (int i = 0; i < num; i++){
string player;
// add player # somehow
cout << "insert Player's name" << endl;
cin >> player;
fullList.push_back(List(player));
}
return fullList;
}
int getRosterSize(){
int size;
cout << "Input # of players in roster" << endl;
cin >> size;
cout << endl;
cout << size << " players allowed in a team" << endl;
cout << endl;
cout << "Randomizing player selection order" << endl;
cout << endl;
return size;
}
void rosterSelectionProcess(vector<List> &fullList){
for (int i = 0; i < fullList.size(); i++){
cout << fullList[i].owner << ", please insert " << rosterNum << " players one by one." << endl;
cout << "If you would like to remove your last pick, type REMOVE and enter" << endl;
int j = 0;
while(j < rosterNum){
cin >> option;
if (option == "REMOVE"){
cout << fullList[i].head->data << " was removed from your list" << endl;
fullList[i].removeHead();
j--;
}
else {
fullList[i].insertFront(option);
j++;
}
}
cout << "Your team selections are: " << endl;
fullList[i].print();
cout << "If you would like to change a player on your team selection, type their name, otherwise type DONE" << endl;
cin >> option;
while (option != "DONE"){
cout << "Add the name of the new player you would like to exchange with" << endl;
cin >> option2;
fullList[i].changeData(option, option2);
cout << "Your updated team selection is:" << endl;
fullList[i].print();
cout << "If you would like to change a player on your team selection, type their name, otherwise type DONE" << endl;
cin >> option;
}
}
}
void drafting(vector<List> &fullList){
int i = 0;
int j = 0;
bool exit = false;
while (!exit){
if (i >= fullList.size()){
i = 0;
}
string owner = fullList[i].owner;
bool escape = false;
while (!escape){
// get node from curret list's index
string value = fullList[i].getDataAtIndex();
auto search = map.find(value);
if (search == map.end()){
map.insert(make_pair(value, owner));
// cout << "inserted draft " << value << " for player " << owner << endl;
fullList[i].incIndex();
// cout << "Index incremented to " << index << endl;
// increment index;
escape = true;
}
else {
int index = fullList[i].getIndex();
if (index == 0){
fullList[i].removeHead();
}
else {
fullList[i].removeAtIndex(index);
}
cout << fullList[i].owner << ", please insert another player" << endl;
cin >> option;
fullList[i].insertBack(option);
}
}
i++;
j++;
if (j >= (rosterNum * fullList.size())) {
exit = true;
}
}
}
void programEnd(vector<List> fullList) {
cout << "Drafting Complete, Reading every participant's roster:" << endl;
for (int i = 0; i < fullList.size(); i++){
cout << fullList[i].owner << "'s roster: " << endl;
fullList[i].print();
}
cout << "Have Fun!" << endl;
}
int main(){
vector<List> fullList = playerInsert();
random_shuffle(begin(fullList), end(fullList));
rosterNum = getRosterSize();
rosterSelectionProcess(fullList);
drafting(fullList);
programEnd(fullList);
}