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

feat: divided viewResults into two funcs

parent 637235d0
Branches
No related tags found
No related merge requests found
......@@ -46,7 +46,7 @@ public:
void calculateScore();
void writeToFilePlayer(ofstream &out);
void readFromFilePlayer(ifstream &in);
void viewResults();
void viewResults(int i);
};
class Tournament
......@@ -66,6 +66,7 @@ public:
// - hvem spiller på hvilket bord
vector<Player *> gPlayers;
vector<Tournament *> gTournaments;
vector<int > gSorting;
// globale verdier:
const int STRLEN = 80;
......@@ -89,6 +90,7 @@ void readFromFile();
void writeToFileTournament();
void readFromFileTournament();
void amntTables();
void viewResults();
int main() {
......@@ -310,26 +312,21 @@ void Tournament::readFromFileTournament(ifstream & in)
*
* @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
void Player::viewResults(int i){
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++){
for(int j= i+1; j<gPlayers.size();i++){ //Sorts result
if(gPlayers[i]->score < gPlayers[j]->score){
temp[i] = gPlayers[j]->score;
}
}
gSorting[i] = gPlayers[j]->score;
}
}
for(int i=0; i<gPlayers.size(); i++){ //For MVP-purposes no scores can be
for(int k=0; k<gPlayers.size(); k++){ //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<< gSorting[k] <<"\t"; //Prints result
for(int j=0; j<gPlayers.size(); j++){
if(gPlayers[j]->score == gSorting[k]){
cout<< gPlayers[j]->name;
}
cout<<"\n";
......@@ -595,3 +592,13 @@ void amntTables(){
cout<<"How many tables do you have?\n";
gTables = lesInt("Tables:",1,200);
}
void viewResults(){
for(int i=0; i < gPlayers.size();i++){
gPlayers[i]->calculateScore();
//Calculates score for every player
for(int i=0; i<gPlayers.size(); i++){
gPlayers->viewResults(i);}
}
\ 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