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
cfc1469c
Commit
cfc1469c
authored
Mar 13, 2019
by
Kyle Malaguit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autosave
parent
6949db4d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
6 deletions
+42
-6
SaveLoad/SaveLoad.cpp
SaveLoad/SaveLoad.cpp
+15
-0
SaveLoad/SaveLoad.h
SaveLoad/SaveLoad.h
+5
-0
SaveLoad/Scores.h
SaveLoad/Scores.h
+5
-2
SaveLoad/errout.txt
SaveLoad/errout.txt
+0
-0
SaveLoad/main.cpp
SaveLoad/main.cpp
+4
-4
SaveLoad/stdout.txt
SaveLoad/stdout.txt
+13
-0
No files found.
SaveLoad/SaveLoad.cpp
View file @
cfc1469c
...
...
@@ -48,3 +48,18 @@ void SaveLoad::userInputNameMakeScore(int intScore){
}
void
SaveLoad
::
printScoreIfLessThan10
(
Scores
findScore
){
vector
<
Scores
>::
iterator
iter
;
cout
<<
"Finding Score..
\n
"
;
iter
=
find
(
scores
.
begin
(),
scores
.
end
(),
findScore
);
if
(
iter
!=
scores
.
end
()){
//use iterator to return position in vector
cout
<<
"Score found "
<<
(
iter
-
scores
.
begin
())
+
1
<<
endl
;
}
else
{
cout
<<
"Score not found"
<<
endl
;
}
// cout << iter << " " << scores.at(iter).getName << " " << scores.at(iter).getScore << endl;
}
\ No newline at end of file
SaveLoad/SaveLoad.h
View file @
cfc1469c
...
...
@@ -28,6 +28,11 @@ class SaveLoad {
//display scores in the bash
void
displayScores
();
//if score is less than top ten print score
void
printScoreIfLessThan10
(
Scores
);
//one that passes a position and returns the line in the vector
//function for comparing
static
bool
sortAscending
(
Scores
,
Scores
);
...
...
SaveLoad/Scores.h
View file @
cfc1469c
...
...
@@ -13,10 +13,13 @@ class Scores{
}
//accessors
string
getName
(){
return
name
;}
int
getScore
(){
return
score
;}
string
getName
()
const
{
return
name
;}
int
getScore
()
const
{
return
score
;}
//overload = so that it can be compared
bool
operator
==
(
const
Scores
&
s
)
const
{
return
this
->
getName
()
==
s
.
getName
()
&&
this
->
getScore
()
==
s
.
getScore
();}
private:
string
name
;
int
score
;
...
...
SaveLoad/errout.txt
0 → 100644
View file @
cfc1469c
SaveLoad/main.cpp
View file @
cfc1469c
...
...
@@ -12,13 +12,13 @@ int main(){
//check for valid username
// char userName[3];
SL2048
second
;
second
.
LoadContainers
();
second
.
userInputNameMakeScore
(
10000
);
second
.
LoadContainers
(
"snakedata.txt"
);
second
.
updateFile
();
second
.
updateFile
(
"snakedata.txt"
);
second
.
displayScores
();
Scores
fScore
(
"cdo"
,
21474
);
second
.
printScoreIfLessThan10
(
fScore
);
return
0
;
...
...
SaveLoad/stdout.txt
0 → 100644
View file @
cfc1469c
Rank Name Score
1 nge 654346
2 vfd 45365
3 cdn 21474
4 ooo 10000
5 LOP 10000
6 vfr 9999
7 ddd 9999
8 Kyl 9999
9 PPP 9999
10 bbb 9999
Finding score rank ...
cdn
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