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

addPlayer, editPlayer functions

parent 966bd77a
No related branches found
No related tags found
No related merge requests found
...@@ -59,9 +59,9 @@ int gRounds = 0; ...@@ -59,9 +59,9 @@ int gRounds = 0;
int gTables = 1; int gTables = 1;
// Funksjoner: // Funksjoner:
void newPlayer(); void addPlayer();
void writePlayer(); void writePlayer();
void updatePlayer(); void editPlayer();
int playerWin(); int playerWin();
Player* findPlayer(const string name); Player* findPlayer(const string name);
Player* findPlayerID(const int ID); Player* findPlayerID(const int ID);
...@@ -88,9 +88,9 @@ char command; ...@@ -88,9 +88,9 @@ char command;
while(command != 'Q') { while(command != 'Q') {
switch(command) { switch(command) {
case 1: newTournament(); break; case 1: newTournament(); break;
case 2: newPlayer(); break; case 2: addPlayer(); break;
case 3: enterResults(); break; case 3: enterResults(); break;
case 4: updatePlayer(); break; case 4: editPlayer(); break;
case 5: viewPlayers(); break; case 5: viewPlayers(); break;
case 6: viewResults(); break; case 6: viewResults(); break;
default: skrivMeny(); break; default: skrivMeny(); break;
...@@ -107,11 +107,6 @@ char command; ...@@ -107,11 +107,6 @@ char command;
* Reads new player * Reads new player
*/ */
void Player::newPlayer() { void Player::newPlayer() {
Player* player;
player = new Player;
cout << "\n\tFull name: "; getline(cin, player->name); cout << "\n\tFull name: "; getline(cin, player->name);
player->rating = lesInt("\n\tRating: ", 1, 10); player->rating = lesInt("\n\tRating: ", 1, 10);
...@@ -120,9 +115,6 @@ void Player::newPlayer() { ...@@ -120,9 +115,6 @@ void Player::newPlayer() {
cout << "\n\tClub: "; getline(cin, player->club); cout << "\n\tClub: "; getline(cin, player->club);
gPlayers.push_back(player);
cout << "\n\nPlayer added!\n\n";
} }
/** /**
...@@ -377,6 +369,43 @@ void newTournament() { ...@@ -377,6 +369,43 @@ void newTournament() {
gRounds++; gRounds++;
} }
/**
* Add a player
*
* @see - Player::newPlayer()
*/
void addPlayer(){
Player* newPlayer;
newPlayer = new Player;
newPlayer->newPlayer();
gPlayers.push_back(newPlayer);
cout << "\n\nPlayer added!\n\n";
}
/**
* edit info about a player
*
* @see - Player::updatePlayer
*/
void editPlayer(){
int choise;
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";
}
else if(choise == 2) {
viewPlayers();
}
/** /**
* *
* *
...@@ -476,7 +505,7 @@ else ...@@ -476,7 +505,7 @@ else
/** /**
* Reads all data about the tournament rounds from file * Reads all data about the tournament rounds from file
*/ */
void readFromFile(){ void readFromFileTournament(){
Tournament* tournamentNew; Tournament* tournamentNew;
ifstream infile("tournamentData.dta"); ifstream infile("tournamentData.dta");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment