Skip to content
Snippets Groups Projects
Commit 637235d0 authored by aurora's avatar aurora
Browse files

fix: move Player::func to right place

parent 0550c084
No related branches found
No related tags found
No related merge requests found
...@@ -305,6 +305,38 @@ void Tournament::readFromFileTournament(ifstream & in) ...@@ -305,6 +305,38 @@ void Tournament::readFromFileTournament(ifstream & in)
} }
} }
/**
* Calculates and prints out scores for all players in descending order
*
* @see - calculateScore()
*/
void Player::viewResults(){
int temp[gPlayers.size()];
for(int i=0; i < gPlayers.size();i++){
gPlayers[i]->calculateScore(); //Calculates score for every player
for(int i=0; i<gPlayers.size(); i++){ //Sorts scores and puts it in an array
for(int j= i+1; j<gPlayers.size();i++){
if(gPlayers[i]->score < gPlayers[j]->score){
temp[i] = gPlayers[j]->score;
}
}
}
}
for(int i=0; i<gPlayers.size(); i++){ //For MVP-purposes no scores can be
//identical
cout<< temp[i] <<"\t";
for(int j=0; j<gPlayers.size(); i++){
if(gPlayers[j]->score == temp[i]){
cout<< gPlayers[j]->name;
}
cout<<"\n";
}
}
}
/** /**
* *
* NON-CLASS FUNCTIONS * NON-CLASS FUNCTIONS
...@@ -341,37 +373,7 @@ void enterResults() ...@@ -341,37 +373,7 @@ void enterResults()
//+1 to draws int of player //+1 to draws int of player
} }
} }
/**
* Calculates and prints out scores for all players in descending order
*
* @see - calculateScore()
*/
void Player::viewResults(){
int temp[gPlayers.size()];
for(int i=0; i < gPlayers.size();i++){
gPlayers[i]->calculateScore(); //Calculates score for every player
for(int i=0; i<gPlayers.size(); i++){ //Sorts scores and puts it in an array
for(int j= i+1; j<gPlayers.size();i++){
if(gPlayers[i]->score < gPlayers[j]->score){
temp[i] = gPlayers[j]->score;
}
}
}
}
for(int i=0; i<gPlayers.size(); i++){ //For MVP-purposes no scores can be
//identical
cout<< temp[i] <<"\t";
for(int j=0; j<gPlayers.size(); i++){
if(gPlayers[j]->score == temp[i]){
cout<< gPlayers[j]->name;
}
cout<<"\n";
}
}
}
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment