From 26772a202527bde19f9e6ee578c15a698ad0a020 Mon Sep 17 00:00:00 2001 From: Kyle Malaguit Date: Mon, 11 Mar 2019 02:39:25 +0000 Subject: [PATCH] autosave --- Testings/Kyle's Folder/2048Data.txt | 13 +++---- Testings/Kyle's Folder/SLSnake.cpp | 2 +- Testings/Kyle's Folder/main.cpp | 51 +++++++++++----------------- Testings/Kyle's Folder/snakedata.txt | 12 +++---- 4 files changed, 33 insertions(+), 45 deletions(-) diff --git a/Testings/Kyle's Folder/2048Data.txt b/Testings/Kyle's Folder/2048Data.txt index e309113..0a7abbd 100644 --- a/Testings/Kyle's Folder/2048Data.txt +++ b/Testings/Kyle's Folder/2048Data.txt @@ -1,6 +1,7 @@ -NAME SCORE DATE -Kyle2 10000 2/23/19 -kyle4 2334 2/26/19 -Kyle3 2000 2/24/19 -Kyle1 1000 2/22/19 -Kyle 100 2/22/19 \ No newline at end of file +NAME SCORE +Mal 54234 +BVB 9240 +BND 6564 +CDS 6544 +NKV 5453 +KAL 2434 diff --git a/Testings/Kyle's Folder/SLSnake.cpp b/Testings/Kyle's Folder/SLSnake.cpp index 34f3b99..cfc827d 100644 --- a/Testings/Kyle's Folder/SLSnake.cpp +++ b/Testings/Kyle's Folder/SLSnake.cpp @@ -32,7 +32,7 @@ void SLSnake::updateFile(){ //delete date in snake data file fout.open("snakedata.txt", ofstream::out | ofstream::trunc); - //update file + //update fout << "NAME" << "\t" << "SCORE" << "\t" << "DATE\n"; for(auto scoresFull : scores){ fout << scoresFull.getName() << "\t" << scoresFull.getScore() << "\t" << scoresFull.getDate() << endl; diff --git a/Testings/Kyle's Folder/main.cpp b/Testings/Kyle's Folder/main.cpp index 6e27d88..b53832b 100644 --- a/Testings/Kyle's Folder/main.cpp +++ b/Testings/Kyle's Folder/main.cpp @@ -14,39 +14,26 @@ int main(){ SLSnake second; second.LoadContainers(); - while(userName != "quit"){ - cout << "Enter a username with a length of 3 characters\n"; - while(strlen(userName) != 3){ - try{ - cin >> userName; - if(strlen(userName) != 3){ - throw runtime_error("Invalid Input. Username must be 3 characters long\n"); - } - } - catch(runtime_error &except){ - cout << except.what(); - } - } - - //here is a temporary score input system - //in the final project the score will be taken automatically from the system. - int score; - cin >> score; - cout << endl; - - //enter date - char date[8]; - cout << "Enter date in --/--/-- format.\nie. 3/9/19\n"; - cin >> date; - - Scores score1(userName, score, date); - second.pushBackNewScoreAndSort(score1); - second.updateFile(); - - second.displayScores(); - + cout << "Enter a username with a length of 3 characters\n"; + cin >> userName; + //here is a temporary score input system + //in the final project the score will be taken automatically from the system. + int score; + cout << "Enter a score: "; + cin >> score; + cout << endl; + + //enter date + char date[8]; + cout << "Enter date in --/--/-- format.\nie. 3/9/19\n"; + cin >> date; + + Scores score1(userName, score, date); + second.pushBackNewScoreAndSort(score1); + second.updateFile(); + + second.displayScores(); - } return 0; diff --git a/Testings/Kyle's Folder/snakedata.txt b/Testings/Kyle's Folder/snakedata.txt index 5ce50ab..c32832b 100644 --- a/Testings/Kyle's Folder/snakedata.txt +++ b/Testings/Kyle's Folder/snakedata.txt @@ -1,7 +1,7 @@ NAME SCORE DATE -Mal 54234 3/11/19 -BVB 9240 3/9/19 -BND 6564 3/9/19 -CDS 6544 3/9/19 -NKV 5453 3/9/19 -KAL 2434 3/10/19 +cdn 2147483647 ğR@ +nge 654346 3/10/19 +vfd 45365 4/6/19 +vfd 4636 4/12/19 +DVS 3423 3/12/19 +dew 343 4/5/19 -- GitLab