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
7ef3e3b1
Commit
7ef3e3b1
authored
Mar 11, 2019
by
Kyle Malaguit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autosave
parent
dde00b28
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
13 deletions
+51
-13
Testings/SaveLoad/SaveLoad.cpp
Testings/SaveLoad/SaveLoad.cpp
+25
-0
Testings/SaveLoad/SaveLoad.h
Testings/SaveLoad/SaveLoad.h
+4
-0
Testings/SaveLoad/Scores.h
Testings/SaveLoad/Scores.h
+1
-0
Testings/SaveLoad/main.cpp
Testings/SaveLoad/main.cpp
+19
-13
Testings/SaveLoad/snakedata.txt
Testings/SaveLoad/snakedata.txt
+2
-0
No files found.
Testings/SaveLoad/SaveLoad.cpp
View file @
7ef3e3b1
...
...
@@ -21,4 +21,29 @@ void SaveLoad::displayScores(){
cout
<<
i
++
<<
"
\t
"
<<
score
.
getName
()
<<
"
\t
"
<<
score
.
getScore
()
<<
endl
;
}
}
void
SaveLoad
::
userInputNameMakeScore
(
int
intScore
){
char
userNameInput
[
3
];
cout
<<
"Please enter a 3 character user name
\n
"
;
do
{
try
{
cin
>>
userNameInput
;
if
(
strlen
(
userNameInput
)
!=
3
){
throw
runtime_error
(
"Invalid User Name input !
\n
"
);
}
break
;
}
catch
(
runtime_error
&
ex
){
cout
<<
ex
.
what
()
<<
endl
;
}
}
while
(
true
);
Scores
*
scorePtr
=
nullptr
;
scorePtr
=
new
Scores
(
userNameInput
,
intScore
);
pushBackNewScoreAndSort
(
*
scorePtr
);
}
\ No newline at end of file
Testings/SaveLoad/SaveLoad.h
View file @
7ef3e3b1
...
...
@@ -3,10 +3,12 @@
#include <fstream>
#include <vector>
#include <cstring>
#include "Scores.h"
#include <map>
#include <string>
#include <algorithm>
#include <stdexcept>
#include <iostream>
using
namespace
std
;
...
...
@@ -23,6 +25,8 @@ class SaveLoad {
static
bool
sortAscending
(
Scores
,
Scores
);
void
userInputNameMakeScore
(
int
intScore
);
//display scores in the bash
void
displayScores
();
...
...
Testings/SaveLoad/Scores.h
View file @
7ef3e3b1
...
...
@@ -16,6 +16,7 @@ class Scores{
string
getName
(){
return
name
;}
int
getScore
(){
return
score
;}
private:
string
name
;
int
score
;
...
...
Testings/SaveLoad/main.cpp
View file @
7ef3e3b1
...
...
@@ -10,24 +10,30 @@ using namespace std;
int
main
(){
//check for valid username
char
userName
[
3
];
//
char userName[3];
SLSnake
second
;
second
.
LoadContainers
();
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
;
Scores
score1
(
userName
,
score
);
second
.
pushBackNewScoreAndSort
(
score1
);
second
.
updateFile
();
// 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;
// Scores score1(userName, score);
// second.pushBackNewScoreAndSort(score1);
// second.updateFile();
// second.displayScores();
second
.
userInputNameMakeScore
(
1000
);
second
.
updateFile
();
second
.
displayScores
();
...
...
Testings/SaveLoad/snakedata.txt
View file @
7ef3e3b1
...
...
@@ -5,4 +5,6 @@ cdn 21474
vfd 4636
vev 4536
DVS 3423
goo 1000
dew 343
bth 34
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