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()
cout << endl << "Player found!";
playerToEdit->printPlayer();
cout << endl;
choice=0;
bool edit = true;
int input;
......
......@@ -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()
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment