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

improvement:edit player changed to global function

parent 4a1686e9
Branches
No related tags found
No related merge requests found
...@@ -159,55 +159,6 @@ Player* findPlayerID(const int ID) { ...@@ -159,55 +159,6 @@ Player* findPlayerID(const int ID) {
} }
} }
/**
* Updates the info of an excisting player
*
* @see viewPlayers()
* @see findPlayer()
* @see findPlayerID()
*/
void Player::updatePlayer() {
int choise,
ID;
string search;
choise = lesInt("\n\t1. Enter info or 2. List",1 , 2);
cout << "\n\n";
if(choise == 1) {
choise = 0;
choise = lesInt("\n\t1. search by name or 2. search by playerID", 1, 2);
cout << "\n\n";
if(choise == 1) {
cout << "\n\tName: "; getline(cin,search);
if(findPlayer(name) == nullptr) {
cout << "\n\tName not recognized!";
} else {
cout << "\n\tPlayer found!\n";
findPlayer(name)->writePlayer();
}
} else if(choise == 2) {
ID = lesInt("\n\tPlayerID: ", 1, 1000);
if(findPlayerID(ID) == nullptr) {
cout << "\n\tPlayerID not recognized!";
} else {
cout << "\n\tPlayer found!\n";
findPlayerID(ID)->writePlayer();
}
}
} else if(choise == 2) {
viewPlayers();
}
} }
/** /**
* Calculates the score for a single player * Calculates the score for a single player
...@@ -400,6 +351,25 @@ void editPlayer(){ ...@@ -400,6 +351,25 @@ void editPlayer(){
choise = 0; choise = 0;
choise = lesInt("\n\t1. search by name or 2. search by playerID", 1, 2); choise = lesInt("\n\t1. search by name or 2. search by playerID", 1, 2);
if(choise == 1){
cout<< "\n\tName: "; getline(cin,search);
if(findPlayer(search) == nullptr) {
cout<< "\n\tName not recognized!\n";
} else{
cout<< "\n\tPlayer found!\n";
findPlayer(search)->writePlayer();
}
}
else if(choise == 2){
findPlayer(search)->ID = lesInt("\n\tPlayerID: ",1, 1000);
if(findPlayerID(ID) == nullptr) {
cout << "\n\tPlayerID not recognized!";
} else {
cout << "\n\tPlayer found!\n";
findPlayerID(ID)->writePlayer();
}
}
cout << "\n\n"; cout << "\n\n";
} }
else if(choise == 2) { else if(choise == 2) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment