Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
1
142GameCenter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nelson Phillips
142GameCenter
Commits
56235ca7
Commit
56235ca7
authored
Mar 11, 2019
by
Kyle Malaguit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autosave
parent
80228ed1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
33 deletions
+21
-33
Testings/SaveLoad/SL2048.cpp
Testings/SaveLoad/SL2048.cpp
+4
-8
Testings/SaveLoad/SLSnake.cpp
Testings/SaveLoad/SLSnake.cpp
+4
-6
Testings/SaveLoad/SaveLoad.cpp
Testings/SaveLoad/SaveLoad.cpp
+2
-2
Testings/SaveLoad/Scores.h
Testings/SaveLoad/Scores.h
+2
-4
Testings/SaveLoad/main.cpp
Testings/SaveLoad/main.cpp
+1
-6
Testings/SaveLoad/snakedata.txt
Testings/SaveLoad/snakedata.txt
+8
-7
No files found.
Testings/SaveLoad/SL2048.cpp
View file @
56235ca7
...
...
@@ -8,10 +8,9 @@ void SL2048::LoadContainers(){
exit
(
0
);
}
string
blank
;
string
name
,
date
;
string
name
;
int
score
;
fin
>>
blank
;
fin
>>
blank
;
fin
>>
blank
;
...
...
@@ -19,14 +18,11 @@ void SL2048::LoadContainers(){
while
(
fin
>>
name
){
//prep variables to store
fin
>>
score
;
fin
>>
date
;
//put into vector
Scores
newScore
(
name
,
score
,
date
);
Scores
newScore
(
name
,
score
);
scores
.
push_back
(
newScore
);
}
cout
<<
endl
<<
scores
.
size
()
<<
endl
;
fin
.
close
();
}
...
...
@@ -34,9 +30,9 @@ void SL2048::updateFile(){
ofstream
fout
;
fout
.
open
(
"2048Data.txt"
,
ofstream
::
out
|
ofstream
::
trunc
);
//delete file contents
fout
<<
"NAME"
<<
"
\t
"
<<
"SCORE"
<<
"
\t
"
<<
"DATE
\n
"
;
fout
<<
"NAME"
<<
"
\t
"
<<
"SCORE"
<<
endl
;
for
(
auto
scoresFull
:
scores
){
fout
<<
scoresFull
.
getName
()
<<
"
\t
"
<<
scoresFull
.
getScore
()
<<
"
\t
"
<<
scoresFull
.
getDate
()
<<
endl
;
fout
<<
scoresFull
.
getName
()
<<
"
\t
"
<<
scoresFull
.
getScore
()
<<
endl
;
}
fout
.
close
();
...
...
Testings/SaveLoad/SLSnake.cpp
View file @
56235ca7
...
...
@@ -8,18 +8,16 @@ void SLSnake::LoadContainers(){
exit
(
0
);
}
string
blank
;
string
name
,
date
;
string
name
;
int
score
;
fin
>>
blank
;
fin
>>
blank
;
fin
>>
blank
;
//read from file intil it isempty
while
(
fin
>>
name
){
fin
>>
score
;
fin
>>
date
;
//put into vector
Scores
newScore
(
name
,
score
,
date
);
Scores
newScore
(
name
,
score
);
scores
.
push_back
(
newScore
);
}
...
...
@@ -33,9 +31,9 @@ void SLSnake::updateFile(){
fout
.
open
(
"snakedata.txt"
,
ofstream
::
out
|
ofstream
::
trunc
);
//update
fout
<<
"NAME"
<<
"
\t
"
<<
"SCORE"
<<
"
\t
"
<<
"DATE
\n
"
;
fout
<<
"NAME"
<<
"
\t
"
<<
"SCORE"
<<
endl
;
for
(
auto
scoresFull
:
scores
){
fout
<<
scoresFull
.
getName
()
<<
"
\t
"
<<
scoresFull
.
getScore
()
<<
"
\t
"
<<
scoresFull
.
getDate
()
<<
endl
;
fout
<<
scoresFull
.
getName
()
<<
"
\t
"
<<
scoresFull
.
getScore
()
<<
endl
;
}
fout
.
close
();
}
\ No newline at end of file
Testings/SaveLoad/SaveLoad.cpp
View file @
56235ca7
...
...
@@ -14,11 +14,11 @@ void SaveLoad::pushBackNewScoreAndSort(Scores Score){
}
void
SaveLoad
::
displayScores
(){
cout
<<
"Rank Name Score
Date
\n
"
;
cout
<<
"Rank Name Score
"
<<
endl
;
int
i
=
1
;
for
(
auto
score
:
scores
){
cout
<<
i
++
<<
"
\t
"
<<
score
.
getName
()
<<
"
\t
"
<<
score
.
getScore
()
<<
"
\t
"
<<
score
.
getDate
()
<<
endl
;
cout
<<
i
++
<<
"
\t
"
<<
score
.
getName
()
<<
"
\t
"
<<
score
.
getScore
()
<<
endl
;
}
}
\ No newline at end of file
Testings/SaveLoad/Scores.h
View file @
56235ca7
...
...
@@ -7,19 +7,17 @@ using namespace std;
class
Scores
{
public:
Scores
(
string
name
,
int
score
,
string
date
){
Scores
(
string
name
,
int
score
){
this
->
name
=
name
;
this
->
score
=
score
;
this
->
date
=
date
;
}
//accessors
string
getName
(){
return
name
;}
int
getScore
(){
return
score
;}
string
getDate
(){
return
date
;}
private:
string
name
,
date
;
string
name
;
int
score
;
};
...
...
Testings/SaveLoad/main.cpp
View file @
56235ca7
...
...
@@ -23,12 +23,7 @@ int main(){
cin
>>
score
;
cout
<<
endl
;
//enter date
char
date
[
8
];
cout
<<
"Enter date in --/--/-- format.
\n
ie. 3/9/19
\n
"
;
cin
>>
date
;
Scores
score1
(
userName
,
score
,
date
);
Scores
score1
(
userName
,
score
);
second
.
pushBackNewScoreAndSort
(
score1
);
second
.
updateFile
();
...
...
Testings/SaveLoad/snakedata.txt
View file @
56235ca7
NAME SCORE DATE
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
NAME SCORE
nge 654346
vfd 45365
cdn 21474
vfd 4636
vev 4536
DVS 3423
dew 343
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment