diff --git a/src/kode/LesData2.h b/src/kode/LesData3.cpp similarity index 88% rename from src/kode/LesData2.h rename to src/kode/LesData3.cpp index 04ce6baa63538b772d9531cbd5a791e470d1bfd8..aa1655a735e99531d99892a5d14b1861522dc036 100644 --- a/src/kode/LesData2.h +++ b/src/kode/LesData3.cpp @@ -1,25 +1,19 @@ /** * Enkel verkt�ykasse 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 */ -#ifndef __LESDATA2_H -#define __LESDATA2_H - - #include <iostream> // cin, cout #include <iomanip> // setprecision #include <cctype> // toupper #include <cstdlib> // atoi, atof - -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); +#include "LesData3.h" // Prototypene for denne filens innhold /** @@ -90,5 +84,3 @@ int lesInt(const char* t, const int min, const int max) { return tall; } - -#endif \ No newline at end of file diff --git a/src/kode/LesData3.h b/src/kode/LesData3.h new file mode 100644 index 0000000000000000000000000000000000000000..61e51fd9fce97a361de50075db650409e4095ed6 --- /dev/null +++ b/src/kode/LesData3.h @@ -0,0 +1,23 @@ +/** + * Enkel verkt�ykasse 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 diff --git a/src/kode/MVP.cpp b/src/kode/MVP.cpp index 2b80432cee5db14642d478b604841b80ac68cbed..f48851dd468e3944da7135c699570ae39eb2aa9a 100644 --- a/src/kode/MVP.cpp +++ b/src/kode/MVP.cpp @@ -6,13 +6,13 @@ * */ - +/* #include <iostream> // cout, cin #include <string> // string #include <vector> // vector #include <iomanip> // setw #include <fstream> // ifstream, ofstream -#include "LesData2.h" +#include "LesData3.h" using namespace std; @@ -116,11 +116,12 @@ void Player::newPlayer(const string nme) { cout << "\n\tPlayers club: "; getline(cin, club); } - +*/ /** * edits selected player from list * */ + /* void Player::editSelectedPlayer() { cout << "\n\tPlayers Name: "; getline(cin, name); @@ -132,11 +133,12 @@ void Player::editSelectedPlayer() { } - +*/ /* * Writes out all info on player * */ +/* void Player::writePlayer() const { @@ -148,13 +150,13 @@ void Player::writePlayer() const << "Amount of draws: " << draws << '\n' << "Amount of wins: " << wins << "\n\n"; } - +*/ /* * Finds player based on name and returns pointer * * @param name * @return Player* - */ + *//* Player *findPlayer(const string name) { for (size_t i = 0; i < gPlayers.size(); i++) @@ -203,12 +205,13 @@ void Tournament::theTournament() { - +*/ /** * Add a player * * @see - Player::newPlayer() */ + /* void addPlayer() { Player *newPlayer; @@ -221,12 +224,12 @@ void addPlayer() gPlayers.push_back(newPlayer); cout << "\n\nPlayer added!\n\n"; } - +*/ /** * Writes out all players and their stats * * @see writePlayer() const - */ + *//* void viewPlayers() { for(size_t i = 0; i < gPlayers.size(); i++){ @@ -234,14 +237,14 @@ void viewPlayers() { gPlayers[i]->writePlayer(); } } - +*/ /** * find player to edit * * @see viewPlayers() * @see editSelectedPlayer() * @see returnName() - */ + *//* void editPlayer() { int choise, @@ -270,11 +273,11 @@ void editPlayer() { } } } - +*/ /** * Sets up a new match * - */ + *//* void newMatch() { string name; int WorD, @@ -320,10 +323,10 @@ void printScore(){ cout<<"\t" <<gPlayers[i]->returnName() <<"\t" <<gPlayers[i]->returnScore() <<"\n"; } } - +*/ /** * writes the programs menu options - */ + *//* void writeMenu() { cout << "\nMenu: \n" @@ -336,3 +339,4 @@ void writeMenu() } +*/ \ No newline at end of file diff --git a/src/kode/Tournament.cpp b/src/kode/Tournament.cpp index 80817878ae6a41592f857f54c516ff1f0b68bb45..dad8d2700c55e1f35884564a0b11e06ff598c0f3 100644 --- a/src/kode/Tournament.cpp +++ b/src/kode/Tournament.cpp @@ -9,7 +9,7 @@ #include <vector> // vector #include <iomanip> // setw #include <fstream> // ifstream, ofstream -#include "LesData2.h" +#include "LesData3.h" #include "player.h" #include "functions.h" diff --git a/src/kode/Tournament.h b/src/kode/Tournament.h index 3fcc8c2516a90c884ed5ab0a0de53826f7f75e39..70faa864c9f78d70a4101726d686970cd9897348 100644 --- a/src/kode/Tournament.h +++ b/src/kode/Tournament.h @@ -10,7 +10,7 @@ #include <vector> // vector #include <iomanip> // setw #include <fstream> // ifstream, ofstream -#include "LesData2.h" +#include "LesData3.h" #include "player.h" using namespace std; diff --git a/src/kode/checkmate.cpp b/src/kode/checkmate.cpp index f565c369e6914797fcc2a3210b1da980e66364f0..a27ab3173b4636caacd9bb5747b9c9da8079c77f 100644 --- a/src/kode/checkmate.cpp +++ b/src/kode/checkmate.cpp @@ -3,7 +3,7 @@ #include <vector> // vector #include <iomanip> // setw #include <fstream> // ifstream, ofstream -#include "LesData2.h" +#include "LesData3.h" #include "player.h" #include "Tournament.h" #include "functions.h" @@ -51,31 +51,35 @@ int main() cout << endl << menuToPrint; command = lesChar("\nCommand: "); - command= tolower(command); + cout << command; switch (command) { - case 's': + case 'S': startNewTournament(); break; - case 'v': + case 'V': viewPlayers(); break; - case 'e': + case 'E': editPlayer(); break; - case 'a': + case 'A': int id; id = lesInt("\nWhat is the new player's ID?\n",0,10000); newPlayer(id); break; - case 'd': + case 'D': deletePlayer(); break; - case 'r': + case 'R': printRanking(); break; - case 'n': - gTournaments[0]->enterResults(); + case 'N': + gTournaments[0]->enterResults(); + break; + case 'Q': + cout << endl << "Closing the program"; + break; default: cout << endl << "Please enter a valid command."; break; diff --git a/src/kode/deletePlayer.cpp b/src/kode/deletePlayer.cpp index 70bb947cf3edf3e8986f5de9a824ebe3eb445440..ba7754e2adc9f27a42a71ecc52191b2f6e8f254e 100644 --- a/src/kode/deletePlayer.cpp +++ b/src/kode/deletePlayer.cpp @@ -2,7 +2,7 @@ #include <string> // STRING-KLASSEN #include "player.h" -#include "LesData2.h" +#include "LesData3.h" #include "functions.h" using namespace std; diff --git a/src/kode/editPlayer.cpp b/src/kode/editPlayer.cpp index 1229449d193ed2c2c0b87890626d053a4f2e666c..a057b64399857b5368b58b34d93a46b15ab28ba5 100644 --- a/src/kode/editPlayer.cpp +++ b/src/kode/editPlayer.cpp @@ -3,7 +3,7 @@ #include <vector> // vector #include <iomanip> // setw #include <fstream> // ifstream, ofstream -#include "LesData2.h" +#include "LesData3.h" #include "player.h" #include "Tournament.h" #include "functions.h" diff --git a/src/kode/newPlayer.cpp b/src/kode/newPlayer.cpp index 5ddf576b1e1c9b738566d66bb17ca6e7cdde890a..340fbe17dff43d515a563a83b2fbd96d7192c494 100644 --- a/src/kode/newPlayer.cpp +++ b/src/kode/newPlayer.cpp @@ -6,7 +6,7 @@ #include <string> // STRING-KLASSEN #include "player.h" -#include "LesData2.h" +#include "LesData3.h" #include "functions.h" using namespace std; diff --git a/src/kode/player.cpp b/src/kode/player.cpp index cb309854aefaf3ddcaff65f8dfbc52c6d7aa5d2b..bac27ed2eacb28e1ea97d844cd7d43c9e7e1fb88 100644 --- a/src/kode/player.cpp +++ b/src/kode/player.cpp @@ -5,9 +5,11 @@ #include <string> // string #include <vector> // vector #include <fstream> // ifstream, ofstream +#include <iostream> // cout, cin +#include <iomanip> // setw #include "player.h" -#include "LesData2.h" +#include "LesData3.h" #include "functions.h" using namespace std; diff --git a/src/kode/printRanking.cpp b/src/kode/printRanking.cpp index 6a18b04710a83602c29f114e82242f1c38baaa73..e0f392e13e67bd40bed1b91186a1fd6bc997b76b 100644 --- a/src/kode/printRanking.cpp +++ b/src/kode/printRanking.cpp @@ -1,9 +1,10 @@ #include <string> // string #include <vector> // vector #include <fstream> // ifstream, ofstream +#include <iostream> // cout, cin #include "player.h" -#include "LesData2.h" +#include "LesData3.h" #include "functions.h" using namespace std; diff --git a/src/kode/startNewTournament.cpp b/src/kode/startNewTournament.cpp index a41f2c46c2e8905832d73eb6291c27d43f70ccb8..26e90d22b91411f4fa3f3be409d9fa5d5025b3f4 100644 --- a/src/kode/startNewTournament.cpp +++ b/src/kode/startNewTournament.cpp @@ -9,7 +9,7 @@ #include <vector> // vector #include <iomanip> // setw #include <fstream> // ifstream, ofstream -#include "LesData2.h" +#include "LesData3.h" #include "player.h" #include "functions.h" @@ -26,9 +26,8 @@ void startNewTournament() cout << endl << "Are you certain you wish to start a new tournament?" << "This will delete all existing tournament data, including the player list."; answer = lesChar(" Y/N\n"); - answer= tolower(answer); - }while (answer != 'y' && answer != 'n'); - if (answer == 'n') + }while (answer != 'Y' && answer != 'N'); + if (answer == 'N') { return; } diff --git a/src/kode/viewPlayers.cpp b/src/kode/viewPlayers.cpp index 567a5f1caf97e295655114210e70f38a0ba292e5..a3637f19cb3e460e5e48f6312f00b6e857559609 100644 --- a/src/kode/viewPlayers.cpp +++ b/src/kode/viewPlayers.cpp @@ -5,7 +5,7 @@ using namespace std; -vector<Player*> playerList; +extern vector<Player*> playerList; /** * Prints a list of all players with identification