Commit 7156b14c authored by Kyle Malaguit's avatar Kyle Malaguit

autosave

parent 962b4c8a
......@@ -5,6 +5,7 @@ vds 10000
NEL 10000
PHI 10000
BAG 10000
mmm 10000
BVB 9240
BND 6564
CDS 6544
......
......@@ -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){
......
......@@ -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
......@@ -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;
......
......@@ -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
......@@ -40,7 +40,6 @@ void SaveLoad::userInputNameMakeScore(int intScore){
}
catch(runtime_error &ex){
cout << ex.what() << endl;
cout << userNameInput << endl;
}
}while(true);
......
......@@ -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> scores;
void pushBackNewScoreAndSort(Scores Score);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment