Commit b83b2342 authored by Nelson Phillips's avatar Nelson Phillips

autosave

parents 2aad108b df7e2698
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define C2048SCORESTATE_H #define C2048SCORESTATE_H
#include "GameState.h" #include "GameState.h"
#include "../Testings/SaveLoad/SL2048.h" #include "../SaveLoad/SL2048.h"
#include <iostream> #include <iostream>
#include <string> #include <string>
......
#include "SL2048.h" #include "SL2048.h"
void SL2048::LoadContainers(){ void SL2048::LoadContainers(string fileName){
ifstream fin; ifstream fin;
fin.open("2048Data.txt"); fin.open(fileName);
if(!fin.is_open()){ if(!fin.is_open()){
cerr << "Could not open file.\n"; cerr << "Could not open file.\n";
exit(0); exit(0);
......
...@@ -15,7 +15,7 @@ using namespace std; ...@@ -15,7 +15,7 @@ using namespace std;
class Scores; class Scores;
class SL2048 : public SaveLoad{ class SL2048 : public SaveLoad{
public: public:
void LoadContainers(); void LoadContainers(string fileName);
void updateFile(string fileName); void updateFile(string fileName);
}; };
......
#include "SLSnake.h" #include "SLSnake.h"
void SLSnake::LoadContainers(){ void SLSnake::LoadContainers(string fileName){
ifstream fin; ifstream fin;
fin.open("snakedata.txt"); fin.open(fileName);
if(!fin.is_open()){ if(!fin.is_open()){
cerr << "Could not open file.\n"; cerr << "Could not open file.\n";
exit(0); exit(0);
......
...@@ -15,7 +15,7 @@ using namespace std; ...@@ -15,7 +15,7 @@ using namespace std;
class Scores; class Scores;
class SLSnake : public SaveLoad{ class SLSnake : public SaveLoad{
public: public:
void LoadContainers(); void LoadContainers(string fileName);
void updateFile(string fileName); void updateFile(string fileName);
}; };
......
...@@ -18,8 +18,8 @@ class SaveLoad { ...@@ -18,8 +18,8 @@ class SaveLoad {
public: public:
//these functions change the files data //these functions change the files data
virtual void LoadContainers() = 0; virtual void LoadContainers(string fileName) = 0;
virtual void updateFile() = 0; virtual void updateFile(string fileName) = 0;
//add new data into file //add new data into file
void sortByScore(); void sortByScore();
......
g++ *.cpp -o main.out -pthread -std=c++11 && ./main.out
\ No newline at end of file
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