Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG1004_2022_group4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Magnus Westerheim Johannessen
PROG1004_2022_group4
Commits
5c3bcc28
Commit
5c3bcc28
authored
3 years ago
by
aurora
Browse files
Options
Downloads
Patches
Plain Diff
feat: viewResults, calculateScore, returnScore
parent
00fff0ee
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kode/MVP.cpp
+24
-1
24 additions, 1 deletion
src/kode/MVP.cpp
with
24 additions
and
1 deletion
src/kode/MVP.cpp
+
24
−
1
View file @
5c3bcc28
...
@@ -42,9 +42,11 @@ Player() {name = club = ""; rating = playerID = wins = draws = score = 0;};
...
@@ -42,9 +42,11 @@ Player() {name = club = ""; rating = playerID = wins = draws = score = 0;};
void
newPlayer
(
const
string
nme
);
void
newPlayer
(
const
string
nme
);
void
writePlayer
()
const
;
void
writePlayer
()
const
;
string
returnName
();
string
returnName
();
float
returnScore
();
void
editSelectedPlayer
();
void
editSelectedPlayer
();
void
addWin
();
void
addWin
();
void
addDraw
();
void
addDraw
();
void
calculateScore
();
};
};
class
Match
:
public
Tournament
{
class
Match
:
public
Tournament
{
...
@@ -71,6 +73,7 @@ void editPlayer();
...
@@ -71,6 +73,7 @@ void editPlayer();
void
viewPlayers
();
void
viewPlayers
();
Player
*
findPlayer
(
const
string
name
);
Player
*
findPlayer
(
const
string
name
);
void
newMatch
();
void
newMatch
();
void
printScore
();
int
main
()
{
int
main
()
{
...
@@ -91,6 +94,7 @@ char command;
...
@@ -91,6 +94,7 @@ char command;
case
'W'
:
viewPlayers
();
break
;
case
'W'
:
viewPlayers
();
break
;
case
'E'
:
editPlayer
();
break
;
case
'E'
:
editPlayer
();
break
;
case
'M'
:
newMatch
();
break
;
case
'M'
:
newMatch
();
break
;
case
'V'
:
printScore
();
break
;
default:
writeMenu
();
break
;
default:
writeMenu
();
break
;
}
}
command
=
lesChar
(
"
\n
Command"
);
command
=
lesChar
(
"
\n
Command"
);
...
@@ -153,7 +157,7 @@ void Player::writePlayer() const
...
@@ -153,7 +157,7 @@ void Player::writePlayer() const
*/
*/
Player
*
findPlayer
(
const
string
name
)
Player
*
findPlayer
(
const
string
name
)
{
{
for
(
in
t
i
=
0
;
i
<
gPlayers
.
size
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
gPlayers
.
size
();
i
++
)
{
{
if
(
gPlayers
[
i
]
->
returnName
()
==
name
)
if
(
gPlayers
[
i
]
->
returnName
()
==
name
)
return
gPlayers
[
i
];
return
gPlayers
[
i
];
...
@@ -165,6 +169,10 @@ string Player::returnName(){
...
@@ -165,6 +169,10 @@ string Player::returnName(){
return
name
;
return
name
;
}
}
float
Player
::
returnScore
(){
return
score
;
}
void
Player
::
addWin
()
{
void
Player
::
addWin
()
{
wins
++
;
wins
++
;
}
}
...
@@ -173,6 +181,11 @@ void Player::addDraw() {
...
@@ -173,6 +181,11 @@ void Player::addDraw() {
draws
++
;
draws
++
;
}
}
void
Player
::
calculateScore
()
{
score
=
draws
*
0.5
+
wins
*
1
;
}
void
Tournament
::
theTournament
()
{
void
Tournament
::
theTournament
()
{
int
matches
;
int
matches
;
...
@@ -299,6 +312,15 @@ void newMatch() {
...
@@ -299,6 +312,15 @@ void newMatch() {
}
}
void
printScore
(){
cout
<<
"
\n
Results:
\n
"
<<
"
\t
Name:
\t
Score:
\n
"
;
for
(
size_t
i
=
0
;
i
<
gPlayers
.
size
();
i
++
){
gPlayers
[
i
]
->
calculateScore
();
cout
<<
"
\t
"
<<
gPlayers
[
i
]
->
returnName
()
<<
"
\t
"
<<
gPlayers
[
i
]
->
returnScore
()
<<
"
\n
"
;
}
}
/**
/**
* writes the programs menu options
* writes the programs menu options
*/
*/
...
@@ -309,6 +331,7 @@ void writeMenu()
...
@@ -309,6 +331,7 @@ void writeMenu()
<<
"
\t
W - view players
\n
"
<<
"
\t
W - view players
\n
"
<<
"
\t
E - Edit player
\n
"
<<
"
\t
E - Edit player
\n
"
<<
"
\t
M - New match
\n
"
<<
"
\t
M - New match
\n
"
<<
"
\t
V - View results
\n
"
<<
"
\t
Q - Quit
\n\n
"
;
<<
"
\t
Q - Quit
\n\n
"
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment