diff --git a/src/kode/editPlayer.cpp b/src/kode/editPlayer.cpp index a057b64399857b5368b58b34d93a46b15ab28ba5..f10024eea1799523bdf818ebd6bd1f4fd3f5e876 100644 --- a/src/kode/editPlayer.cpp +++ b/src/kode/editPlayer.cpp @@ -59,6 +59,7 @@ void editPlayer() cout << endl << "Player found!"; playerToEdit->printPlayer(); + cout << endl; choice=0; bool edit = true; int input; diff --git a/src/kode/player.cpp b/src/kode/player.cpp index bac27ed2eacb28e1ea97d844cd7d43c9e7e1fb88..d6e4cbb2f7971a29218afd3f31adcc563bbbe5f7 100644 --- a/src/kode/player.cpp +++ b/src/kode/player.cpp @@ -52,8 +52,12 @@ void Player::printPlayer() << endl << "Club: " << club << endl << "Rating: " << rating << endl << "ID: " << playerID << endl - << "Current score: " << score << endl - << "Current rank in tournament: " << currentRank(playerID) << endl; + << "Current score: " << score << endl; + if (results.size()>0) + { + cout << "Current rank in tournament: " << currentRank(playerID) << endl; + } + } void Player::printPlayerTable() diff --git a/src/kode/searchByName.cpp b/src/kode/searchByName.cpp index f10fb38d7b89ad422fdca522dd15b68d8680da4a..49bea267902c5e55900fd768d8755b8d3311641a 100644 --- a/src/kode/searchByName.cpp +++ b/src/kode/searchByName.cpp @@ -8,6 +8,7 @@ extern vector<Player*> playerList; int searchByName(string name) { + vector<Player*> searchlist; string playerName; int findSize = 0; int finds[10]; @@ -20,33 +21,41 @@ int searchByName(string name) { name[i] = tolower(name[i]); } - for (f = 0; f < playerList.size(); f++) { + for (f = 0; f < playerList.size(); f++) + { playerName = playerList.at(f)->firstName; - for (int j = 0; j < playerList.at(f)->firstName.length(); j++) { + for (int j = 0; j < playerList.at(f)->firstName.length(); j++) + { playerName[j] = tolower(playerName[j]); } - if (playerName.find(name) == 0) { + if (playerName.find(name) == 0) + { finds[findSize] = f; findSize += 1; } } - for (l = 0; l < playerList.size(); l++) { + for (l = 0; l < playerList.size(); l++) + { playerName = playerList.at(l)->lastName; - for (int j = 0; j < playerList.at(l)->lastName.length(); j++) { + for (int j = 0; j < playerList.at(l)->lastName.length(); j++) + { playerName[j] = tolower(playerName[j]); } - if (playerName.find(name) == 0) { - finds[findSize] = l + f; + if (playerName.find(name) == 0) + { + finds[findSize] = l; findSize += 1; } } - if(findSize > 1) { + if(findSize > 1) + { cout << endl << "Choose one of these players " << endl; - for (int i = 0; i < findSize; i++) { + for (int i = 0; i < findSize; i++) + { cout << i+1 << ": " << playerList.at(finds[i])->lastName << ", " << playerList.at(finds[i])->firstName << endl; } @@ -54,10 +63,12 @@ int searchByName(string name) return finds[answer - 1]; } - else if(findSize == 1) { + else if(findSize == 1) + { return finds[0]; } - else { + else + { return -1; } } \ No newline at end of file