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

Finished

parent eb99d018
No related branches found
No related tags found
No related merge requests found
/** /**
* Enkel verktykasse for lese: tegn og tall. * Enkel verktykasse for lese: tegn og tall.
* *
* @file LesData2.H * FULLSTENDIG IDENTISK til 'LesData2.h' bare at adskilt
* funksjonenes DEKLARASJON og DEFINISJON (som er p DENNE filen).
*
* @file LesData3.CPP
* @author Frode Haug, NTNU * @author Frode Haug, NTNU
*/ */
#ifndef __LESDATA2_H
#define __LESDATA2_H
#include <iostream> // cin, cout #include <iostream> // cin, cout
#include <iomanip> // setprecision #include <iomanip> // setprecision
#include <cctype> // toupper #include <cctype> // toupper
#include <cstdlib> // atoi, atof #include <cstdlib> // atoi, atof
#include "LesData3.h" // Prototypene for denne filens innhold
const int MAXCHAR = 200; // Max.tegn i input-buffer.
char lesChar(const char* t);
float lesFloat(const char* t, const float min, const float max);
int lesInt(const char* t, const int min, const int max);
/** /**
...@@ -90,5 +84,3 @@ int lesInt(const char* t, const int min, const int max) { ...@@ -90,5 +84,3 @@ int lesInt(const char* t, const int min, const int max) {
return tall; return tall;
} }
#endif
\ No newline at end of file
/**
* Enkel verktykasse for lese: tegn og tall.
*
* FULLSTENDIG IDENTISK til 'LesData2.h' bare at adskilt
* funksjonenes DEKLARASJON (som er p DENNE filen) og DEFINISJON.
*
* @file LesData3.H
* @author Frode Haug, NTNU
*/
#ifndef __LESDATA3_H
#define __LESDATA3_H
const int MAXCHAR = 200; // Max.tegn i input-buffer.
char lesChar(const char* t);
float lesFloat(const char* t, const float min, const float max);
int lesInt(const char* t, const int min, const int max);
#endif
\ No newline at end of file
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
* *
*/ */
/*
#include <iostream> // cout, cin #include <iostream> // cout, cin
#include <string> // string #include <string> // string
#include <vector> // vector #include <vector> // vector
#include <iomanip> // setw #include <iomanip> // setw
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include "LesData2.h" #include "LesData3.h"
using namespace std; using namespace std;
...@@ -116,11 +116,12 @@ void Player::newPlayer(const string nme) { ...@@ -116,11 +116,12 @@ void Player::newPlayer(const string nme) {
cout << "\n\tPlayers club: "; getline(cin, club); cout << "\n\tPlayers club: "; getline(cin, club);
} }
*/
/** /**
* edits selected player from list * edits selected player from list
* *
*/ */
/*
void Player::editSelectedPlayer() { void Player::editSelectedPlayer() {
cout << "\n\tPlayers Name: "; getline(cin, name); cout << "\n\tPlayers Name: "; getline(cin, name);
...@@ -132,11 +133,12 @@ void Player::editSelectedPlayer() { ...@@ -132,11 +133,12 @@ void Player::editSelectedPlayer() {
} }
*/
/* /*
* Writes out all info on player * Writes out all info on player
* *
*/ */
/*
void Player::writePlayer() const void Player::writePlayer() const
{ {
...@@ -148,13 +150,13 @@ void Player::writePlayer() const ...@@ -148,13 +150,13 @@ void Player::writePlayer() const
<< "Amount of draws: " << draws << '\n' << "Amount of draws: " << draws << '\n'
<< "Amount of wins: " << wins << "\n\n"; << "Amount of wins: " << wins << "\n\n";
} }
*/
/* /*
* Finds player based on name and returns pointer * Finds player based on name and returns pointer
* *
* @param name * @param name
* @return Player* * @return Player*
*/ *//*
Player *findPlayer(const string name) Player *findPlayer(const string name)
{ {
for (size_t i = 0; i < gPlayers.size(); i++) for (size_t i = 0; i < gPlayers.size(); i++)
...@@ -203,12 +205,13 @@ void Tournament::theTournament() { ...@@ -203,12 +205,13 @@ void Tournament::theTournament() {
*/
/** /**
* Add a player * Add a player
* *
* @see - Player::newPlayer() * @see - Player::newPlayer()
*/ */
/*
void addPlayer() void addPlayer()
{ {
Player *newPlayer; Player *newPlayer;
...@@ -221,12 +224,12 @@ void addPlayer() ...@@ -221,12 +224,12 @@ void addPlayer()
gPlayers.push_back(newPlayer); gPlayers.push_back(newPlayer);
cout << "\n\nPlayer added!\n\n"; cout << "\n\nPlayer added!\n\n";
} }
*/
/** /**
* Writes out all players and their stats * Writes out all players and their stats
* *
* @see writePlayer() const * @see writePlayer() const
*/ *//*
void viewPlayers() { void viewPlayers() {
for(size_t i = 0; i < gPlayers.size(); i++){ for(size_t i = 0; i < gPlayers.size(); i++){
...@@ -234,14 +237,14 @@ void viewPlayers() { ...@@ -234,14 +237,14 @@ void viewPlayers() {
gPlayers[i]->writePlayer(); gPlayers[i]->writePlayer();
} }
} }
*/
/** /**
* find player to edit * find player to edit
* *
* @see viewPlayers() * @see viewPlayers()
* @see editSelectedPlayer() * @see editSelectedPlayer()
* @see returnName() * @see returnName()
*/ *//*
void editPlayer() { void editPlayer() {
int choise, int choise,
...@@ -270,11 +273,11 @@ void editPlayer() { ...@@ -270,11 +273,11 @@ void editPlayer() {
} }
} }
} }
*/
/** /**
* Sets up a new match * Sets up a new match
* *
*/ *//*
void newMatch() { void newMatch() {
string name; string name;
int WorD, int WorD,
...@@ -320,10 +323,10 @@ void printScore(){ ...@@ -320,10 +323,10 @@ void printScore(){
cout<<"\t" <<gPlayers[i]->returnName() <<"\t" <<gPlayers[i]->returnScore() <<"\n"; cout<<"\t" <<gPlayers[i]->returnName() <<"\t" <<gPlayers[i]->returnScore() <<"\n";
} }
} }
*/
/** /**
* writes the programs menu options * writes the programs menu options
*/ *//*
void writeMenu() void writeMenu()
{ {
cout << "\nMenu: \n" cout << "\nMenu: \n"
...@@ -336,3 +339,4 @@ void writeMenu() ...@@ -336,3 +339,4 @@ void writeMenu()
} }
*/
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <vector> // vector #include <vector> // vector
#include <iomanip> // setw #include <iomanip> // setw
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include "LesData2.h" #include "LesData3.h"
#include "player.h" #include "player.h"
#include "functions.h" #include "functions.h"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <vector> // vector #include <vector> // vector
#include <iomanip> // setw #include <iomanip> // setw
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include "LesData2.h" #include "LesData3.h"
#include "player.h" #include "player.h"
using namespace std; using namespace std;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <vector> // vector #include <vector> // vector
#include <iomanip> // setw #include <iomanip> // setw
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include "LesData2.h" #include "LesData3.h"
#include "player.h" #include "player.h"
#include "Tournament.h" #include "Tournament.h"
#include "functions.h" #include "functions.h"
...@@ -51,31 +51,35 @@ int main() ...@@ -51,31 +51,35 @@ int main()
cout << endl << menuToPrint; cout << endl << menuToPrint;
command = lesChar("\nCommand: "); command = lesChar("\nCommand: ");
command= tolower(command); cout << command;
switch (command) switch (command)
{ {
case 's': case 'S':
startNewTournament(); startNewTournament();
break; break;
case 'v': case 'V':
viewPlayers(); viewPlayers();
break; break;
case 'e': case 'E':
editPlayer(); editPlayer();
break; break;
case 'a': case 'A':
int id; int id;
id = lesInt("\nWhat is the new player's ID?\n",0,10000); id = lesInt("\nWhat is the new player's ID?\n",0,10000);
newPlayer(id); newPlayer(id);
break; break;
case 'd': case 'D':
deletePlayer(); deletePlayer();
break; break;
case 'r': case 'R':
printRanking(); printRanking();
break; break;
case 'n': case 'N':
gTournaments[0]->enterResults(); gTournaments[0]->enterResults();
break;
case 'Q':
cout << endl << "Closing the program";
break;
default: default:
cout << endl << "Please enter a valid command."; cout << endl << "Please enter a valid command.";
break; break;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <string> // STRING-KLASSEN #include <string> // STRING-KLASSEN
#include "player.h" #include "player.h"
#include "LesData2.h" #include "LesData3.h"
#include "functions.h" #include "functions.h"
using namespace std; using namespace std;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <vector> // vector #include <vector> // vector
#include <iomanip> // setw #include <iomanip> // setw
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include "LesData2.h" #include "LesData3.h"
#include "player.h" #include "player.h"
#include "Tournament.h" #include "Tournament.h"
#include "functions.h" #include "functions.h"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <string> // STRING-KLASSEN #include <string> // STRING-KLASSEN
#include "player.h" #include "player.h"
#include "LesData2.h" #include "LesData3.h"
#include "functions.h" #include "functions.h"
using namespace std; using namespace std;
......
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
#include <string> // string #include <string> // string
#include <vector> // vector #include <vector> // vector
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include <iostream> // cout, cin
#include <iomanip> // setw
#include "player.h" #include "player.h"
#include "LesData2.h" #include "LesData3.h"
#include "functions.h" #include "functions.h"
using namespace std; using namespace std;
......
#include <string> // string #include <string> // string
#include <vector> // vector #include <vector> // vector
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include <iostream> // cout, cin
#include "player.h" #include "player.h"
#include "LesData2.h" #include "LesData3.h"
#include "functions.h" #include "functions.h"
using namespace std; using namespace std;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <vector> // vector #include <vector> // vector
#include <iomanip> // setw #include <iomanip> // setw
#include <fstream> // ifstream, ofstream #include <fstream> // ifstream, ofstream
#include "LesData2.h" #include "LesData3.h"
#include "player.h" #include "player.h"
#include "functions.h" #include "functions.h"
...@@ -26,9 +26,8 @@ void startNewTournament() ...@@ -26,9 +26,8 @@ void startNewTournament()
cout << endl << "Are you certain you wish to start a new tournament?" cout << endl << "Are you certain you wish to start a new tournament?"
<< "This will delete all existing tournament data, including the player list."; << "This will delete all existing tournament data, including the player list.";
answer = lesChar(" Y/N\n"); answer = lesChar(" Y/N\n");
answer= tolower(answer); }while (answer != 'Y' && answer != 'N');
}while (answer != 'y' && answer != 'n'); if (answer == 'N')
if (answer == 'n')
{ {
return; return;
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
using namespace std; using namespace std;
vector<Player*> playerList; extern vector<Player*> playerList;
/** /**
* Prints a list of all players with identification * Prints a list of all players with identification
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment