From f30361f7940ee86bfbda8029f8745e2961f7ce7a Mon Sep 17 00:00:00 2001 From: TheHresvelgian <sigrunhog@hotmail.com> Date: Wed, 27 Apr 2022 20:52:48 +0200 Subject: [PATCH] Finished --- src/kode/{LesData2.h => LesData3.cpp} | 18 ++++---------- src/kode/LesData3.h | 23 ++++++++++++++++++ src/kode/MVP.cpp | 34 +++++++++++++++------------ src/kode/Tournament.cpp | 2 +- src/kode/Tournament.h | 2 +- src/kode/checkmate.cpp | 24 +++++++++++-------- src/kode/deletePlayer.cpp | 2 +- src/kode/editPlayer.cpp | 2 +- src/kode/newPlayer.cpp | 2 +- src/kode/player.cpp | 4 +++- src/kode/printRanking.cpp | 3 ++- src/kode/startNewTournament.cpp | 7 +++--- src/kode/viewPlayers.cpp | 2 +- 13 files changed, 75 insertions(+), 50 deletions(-) rename src/kode/{LesData2.h => LesData3.cpp} (88%) create mode 100644 src/kode/LesData3.h 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 04ce6ba..aa1655a 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 0000000..61e51fd --- /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 2b80432..f48851d 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 8081787..dad8d27 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 3fcc8c2..70faa86 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 f565c36..a27ab31 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 70bb947..ba7754e 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 1229449..a057b64 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 5ddf576..340fbe1 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 cb30985..bac27ed 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 6a18b04..e0f392e 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 a41f2c4..26e90d2 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 567a5f1..a3637f1 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 -- GitLab