Skip to content
Snippets Groups Projects
Commit 55c48b68 authored by TheHresvelgian's avatar TheHresvelgian
Browse files

fixed a bug in edit player

parent aea746b9
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,7 @@ void editPlayer() ...@@ -59,6 +59,7 @@ void editPlayer()
cout << endl << "Player found!"; cout << endl << "Player found!";
playerToEdit->printPlayer(); playerToEdit->printPlayer();
cout << endl;
choice=0; choice=0;
bool edit = true; bool edit = true;
int input; int input;
......
...@@ -52,8 +52,12 @@ void Player::printPlayer() ...@@ -52,8 +52,12 @@ void Player::printPlayer()
<< endl << "Club: " << club << endl << endl << "Club: " << club << endl
<< "Rating: " << rating << endl << "Rating: " << rating << endl
<< "ID: " << playerID << endl << "ID: " << playerID << endl
<< "Current score: " << score << endl << "Current score: " << score << endl;
<< "Current rank in tournament: " << currentRank(playerID) << endl; if (results.size()>0)
{
cout << "Current rank in tournament: " << currentRank(playerID) << endl;
}
} }
void Player::printPlayerTable() void Player::printPlayerTable()
......
...@@ -8,6 +8,7 @@ extern vector<Player*> playerList; ...@@ -8,6 +8,7 @@ extern vector<Player*> playerList;
int searchByName(string name) int searchByName(string name)
{ {
vector<Player*> searchlist;
string playerName; string playerName;
int findSize = 0; int findSize = 0;
int finds[10]; int finds[10];
...@@ -20,33 +21,41 @@ int searchByName(string name) ...@@ -20,33 +21,41 @@ int searchByName(string name)
{ {
name[i] = tolower(name[i]); name[i] = tolower(name[i]);
} }
for (f = 0; f < playerList.size(); f++) { for (f = 0; f < playerList.size(); f++)
{
playerName = playerList.at(f)->firstName; 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]); playerName[j] = tolower(playerName[j]);
} }
if (playerName.find(name) == 0) { if (playerName.find(name) == 0)
{
finds[findSize] = f; finds[findSize] = f;
findSize += 1; findSize += 1;
} }
} }
for (l = 0; l < playerList.size(); l++) { for (l = 0; l < playerList.size(); l++)
{
playerName = playerList.at(l)->lastName; 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]); playerName[j] = tolower(playerName[j]);
} }
if (playerName.find(name) == 0) { if (playerName.find(name) == 0)
finds[findSize] = l + f; {
finds[findSize] = l;
findSize += 1; findSize += 1;
} }
} }
if(findSize > 1) { if(findSize > 1)
{
cout << endl << "Choose one of these players " << endl; 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 << ", " cout << i+1 << ": " << playerList.at(finds[i])->lastName << ", "
<< playerList.at(finds[i])->firstName << endl; << playerList.at(finds[i])->firstName << endl;
} }
...@@ -54,10 +63,12 @@ int searchByName(string name) ...@@ -54,10 +63,12 @@ int searchByName(string name)
return finds[answer - 1]; return finds[answer - 1];
} }
else if(findSize == 1) { else if(findSize == 1)
{
return finds[0]; return finds[0];
} }
else { else
{
return -1; return -1;
} }
} }
\ 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