diff --git a/Testings/SaveLoad/2048Data.txt b/Testings/SaveLoad/2048Data.txt index b7ebd1cf0abf546bb5092abae9219adf784e562d..918853fbada5f43393185742e7603d68328af1b9 100644 --- a/Testings/SaveLoad/2048Data.txt +++ b/Testings/SaveLoad/2048Data.txt @@ -5,6 +5,7 @@ vds 10000 NEL 10000 PHI 10000 BAG 10000 +mmm 10000 BVB 9240 BND 6564 CDS 6544 diff --git a/Testings/SaveLoad/SL2048.cpp b/Testings/SaveLoad/SL2048.cpp index b88cea4b2225d6a1b2f38ca9da1b5c29af16c687..b75ca640afe9e0b20ac86ffd0da69813d30e3d15 100644 --- a/Testings/SaveLoad/SL2048.cpp +++ b/Testings/SaveLoad/SL2048.cpp @@ -26,9 +26,10 @@ void SL2048::LoadContainers(){ fin.close(); } -void SL2048::updateFile(){ +void SL2048::updateFile(string fileName){ + ofstream fout; - fout.open("2048Data.txt", ofstream::out | ofstream::trunc); + fout.open(fileName, ofstream::out | ofstream::trunc); //delete file contents fout << "NAME" << "\t" << "SCORE" << endl; for(auto scoresFull : scores){ diff --git a/Testings/SaveLoad/SL2048.h b/Testings/SaveLoad/SL2048.h index 21374be8e4b36babeadd5d231d933fb2f5813687..e6c0c0fae81e3c2e5e738c02cb536a766e07dd68 100644 --- a/Testings/SaveLoad/SL2048.h +++ b/Testings/SaveLoad/SL2048.h @@ -16,7 +16,7 @@ class Scores; class SL2048 : public SaveLoad{ public: void LoadContainers(); - void updateFile(); + void updateFile(string fileName); }; #endif \ No newline at end of file diff --git a/Testings/SaveLoad/SLSnake.cpp b/Testings/SaveLoad/SLSnake.cpp index 5da914b4c6b15f33c9ee815647641a2678967f4d..68601ca333af75ab975874ce9e8b30c25b7e7025 100644 --- a/Testings/SaveLoad/SLSnake.cpp +++ b/Testings/SaveLoad/SLSnake.cpp @@ -25,10 +25,10 @@ void SLSnake::LoadContainers(){ fin.close(); } -void SLSnake::updateFile(){ +void SLSnake::updateFile(string fileName){ ofstream fout; //delete date in snake data file - fout.open("snakedata.txt", ofstream::out | ofstream::trunc); + fout.open(fileName, ofstream::out | ofstream::trunc); //update fout << "NAME" << "\t" << "SCORE" << endl; diff --git a/Testings/SaveLoad/SLSnake.h b/Testings/SaveLoad/SLSnake.h index ac938190fca13ce018377fccdd97f6a42e091a11..6a5901239c1008b9c140eb53e5ad1f353ce58de7 100644 --- a/Testings/SaveLoad/SLSnake.h +++ b/Testings/SaveLoad/SLSnake.h @@ -16,7 +16,7 @@ class Scores; class SLSnake : public SaveLoad{ public: void LoadContainers(); - void updateFile(); + void updateFile(string fileName); }; #endif \ No newline at end of file diff --git a/Testings/SaveLoad/SaveLoad.cpp b/Testings/SaveLoad/SaveLoad.cpp index 21a238e7b43839d574be01934657cbb5231c750c..6d6e8c2357191ece6f635e2a81dd26d94695cac3 100644 --- a/Testings/SaveLoad/SaveLoad.cpp +++ b/Testings/SaveLoad/SaveLoad.cpp @@ -40,7 +40,6 @@ void SaveLoad::userInputNameMakeScore(int intScore){ } catch(runtime_error &ex){ cout << ex.what() << endl; - cout << userNameInput << endl; } }while(true); diff --git a/Testings/SaveLoad/SaveLoad.h b/Testings/SaveLoad/SaveLoad.h index 633892c47af7b4efd5d898d9eafe99b393b0f6e8..4ebd7d9c2b3fa19214c378a0866d99bb54c83d0f 100644 --- a/Testings/SaveLoad/SaveLoad.h +++ b/Testings/SaveLoad/SaveLoad.h @@ -16,22 +16,24 @@ using namespace std; class Scores; class SaveLoad { public: + + //these functions change the files data virtual void LoadContainers() = 0; virtual void updateFile() = 0; //add new data into file - void pushBackNewScoreAndSort(Scores Score); void sortByScore(); - - static bool sortAscending(Scores, Scores); - void userInputNameMakeScore(int intScore); //display scores in the bash void displayScores(); + //function for comparing + static bool sortAscending(Scores, Scores); + protected: vector scores; + void pushBackNewScoreAndSort(Scores Score); };