Commit 26772a20 authored by Kyle Malaguit's avatar Kyle Malaguit

autosave

parent 97b8f0e2
NAME SCORE DATE NAME SCORE
Kyle2 10000 2/23/19 Mal 54234
kyle4 2334 2/26/19 BVB 9240
Kyle3 2000 2/24/19 BND 6564
Kyle1 1000 2/22/19 CDS 6544
Kyle 100 2/22/19 NKV 5453
\ No newline at end of file KAL 2434
...@@ -32,7 +32,7 @@ void SLSnake::updateFile(){ ...@@ -32,7 +32,7 @@ void SLSnake::updateFile(){
//delete date in snake data file //delete date in snake data file
fout.open("snakedata.txt", ofstream::out | ofstream::trunc); fout.open("snakedata.txt", ofstream::out | ofstream::trunc);
//update file //update
fout << "NAME" << "\t" << "SCORE" << "\t" << "DATE\n"; fout << "NAME" << "\t" << "SCORE" << "\t" << "DATE\n";
for(auto scoresFull : scores){ for(auto scoresFull : scores){
fout << scoresFull.getName() << "\t" << scoresFull.getScore() << "\t" << scoresFull.getDate() << endl; fout << scoresFull.getName() << "\t" << scoresFull.getScore() << "\t" << scoresFull.getDate() << endl;
......
...@@ -14,39 +14,26 @@ int main(){ ...@@ -14,39 +14,26 @@ int main(){
SLSnake second; SLSnake second;
second.LoadContainers(); second.LoadContainers();
while(userName != "quit"){ cout << "Enter a username with a length of 3 characters\n";
cout << "Enter a username with a length of 3 characters\n"; cin >> userName;
while(strlen(userName) != 3){ //here is a temporary score input system
try{ //in the final project the score will be taken automatically from the system.
cin >> userName; int score;
if(strlen(userName) != 3){ cout << "Enter a score: ";
throw runtime_error("Invalid Input. Username must be 3 characters long\n"); cin >> score;
} cout << endl;
}
catch(runtime_error &except){ //enter date
cout << except.what(); char date[8];
} cout << "Enter date in --/--/-- format.\nie. 3/9/19\n";
} cin >> date;
//here is a temporary score input system Scores score1(userName, score, date);
//in the final project the score will be taken automatically from the system. second.pushBackNewScoreAndSort(score1);
int score; second.updateFile();
cin >> score;
cout << endl; second.displayScores();
//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; return 0;
......
NAME SCORE DATE NAME SCORE DATE
Mal 54234 3/11/19 cdn 2147483647 ðR@
BVB 9240 3/9/19 nge 654346 3/10/19
BND 6564 3/9/19 vfd 45365 4/6/19
CDS 6544 3/9/19 vfd 4636 4/12/19
NKV 5453 3/9/19 DVS 3423 3/12/19
KAL 2434 3/10/19 dew 343 4/5/19
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