Skip to content
Snippets Groups Projects
Commit 7b18cbb2 authored by TheHresvelgian's avatar TheHresvelgian
Browse files

fixed bug with printing menu and adding new players id as well as printing incorrect table number

parent a0dcf355
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@
*/
char lesChar(const char* t) {
char tegn;
std::cout << t << ": ";
std::cout << t;
std::cin >> tegn; std::cin.ignore(MAXCHAR, '\n');
return (toupper(tegn));
}
......
......@@ -25,7 +25,7 @@ void Tournament::enterResults()
for (int i = 0; i < nrOfTables; ++i)
{
int answer;
cout << endl << "Enter results for table " << i << "with "
cout << endl << "Enter results for table " << i+1 << "with "
<< playerList[searchByID(white[i],1)]->lastName
<< " as white and "
<< playerList[searchByID(black[i],1)]->lastName
......@@ -57,6 +57,7 @@ void Tournament::enterResults()
if(currentRound == nrOfRounds)
{
finished=true;
endTournament();
}
else
......@@ -78,7 +79,7 @@ void Tournament::printTables()
currentRound++;
if (currentRound == 0)
if (currentRound == 1)
{
vector<Player*> playersPlaying = playerList;
for (int i = 0; i < nrOfTables; ++i)
......
......@@ -27,6 +27,7 @@ class Tournament
int nrOfRounds; //amount of rounds the tournament has total
vector<int>white; //id of the players with white pieces in the current round, so white[0] is the id of the player with white pieces on table 1
vector<int>black; //id of the players with black pieces in the current round, so black[0] is the id of the player with black pieces on table 1
bool finished;
//white and black are reset each round, but still needs to be saved
virtual void enterResults(); //Enters the results after a round, goes through each table and asks the result before allowing the next round to start
......
......@@ -28,8 +28,8 @@ int main()
{
char command;
readFromFile();
readFromFileTournament();
// readFromFile();
// readFromFileTournament();
do
{
......@@ -41,7 +41,7 @@ int main()
{
menuToPrint=menuSetUp;
}
else if (gTournaments[0]->nrOfRounds==gTournaments[0]->white.size())
else if (gTournaments[0]->finished)
{
menuToPrint=menuEnd;
}
......@@ -52,7 +52,7 @@ int main()
cout << endl << menuToPrint;
command = lesChar("\nCommand: ");
cout << command;
// cout << command;
switch (command)
{
case 'S':
......@@ -91,8 +91,8 @@ int main()
}while (command != 'Q');
writeToFileTournament();
writeToFile();
// writeToFileTournament();
// writeToFile();
return 0;
}
......
......@@ -16,11 +16,14 @@ extern vector<Player*>playerList;
void newPlayer(int id)
{
Player* newPlayer;
if (searchByID(id,1)!=-1)
{
do
{
cout << endl << "A player with this ID already exists, please try again!" << endl;
id = lesInt("Please offer a valid ID\n",0,10000);
}while(searchByID(id,1)!=-1);
}
newPlayer = new Player;
newPlayer->playerID = id;
cout << endl << "Last name of player " << id << endl;
......
......@@ -41,5 +41,6 @@ void startNewTournament()
newTournament->nrOfTables = lesInt("\nHow many tables should the tournament have?\n",1,1000);
newTournament->currentRound = 0;
newTournament->nrOfRounds = lesInt("\nHow many rounds should the tournament have?\n",1,20);
newTournament->finished=false;
gTournaments.push_back(newTournament);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment