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
e0adf4b6
Commit
e0adf4b6
authored
3 years ago
by
aurora
Browse files
Options
Downloads
Patches
Plain Diff
feat: divided viewResults into two funcs
parent
637235d0
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/checkmate.cpp
+25
-18
25 additions, 18 deletions
src/kode/checkmate.cpp
with
25 additions
and
18 deletions
src/kode/checkmate.cpp
+
25
−
18
View file @
e0adf4b6
...
...
@@ -46,7 +46,7 @@ public:
void
calculateScore
();
void
writeToFilePlayer
(
ofstream
&
out
);
void
readFromFilePlayer
(
ifstream
&
in
);
void
viewResults
();
void
viewResults
(
int
i
);
};
class
Tournament
...
...
@@ -66,6 +66,7 @@ public:
// - hvem spiller på hvilket bord
vector
<
Player
*>
gPlayers
;
vector
<
Tournament
*>
gTournaments
;
vector
<
int
>
gSorting
;
// globale verdier:
const
int
STRLEN
=
80
;
...
...
@@ -89,6 +90,7 @@ void readFromFile();
void
writeToFileTournament
();
void
readFromFileTournament
();
void
amntTables
();
void
viewResults
();
int
main
()
{
...
...
@@ -310,26 +312,21 @@ void Tournament::readFromFileTournament(ifstream & in)
*
* @see - calculateScore()
*/
void
Player
::
viewResults
(){
int
temp
[
gPlayers
.
size
()];
for
(
int
i
=
0
;
i
<
gPlayers
.
size
();
i
++
){
gPlayers
[
i
]
->
calculateScore
();
//Calculates score for every player
void
Player
::
viewResults
(
int
i
){
for
(
int
i
=
0
;
i
<
gPlayers
.
size
();
i
++
){
//Sorts scores and puts it in an array
for
(
int
j
=
i
+
1
;
j
<
gPlayers
.
size
();
i
++
){
for
(
int
j
=
i
+
1
;
j
<
gPlayers
.
size
();
i
++
){
//Sorts result
if
(
gPlayers
[
i
]
->
score
<
gPlayers
[
j
]
->
score
){
temp
[
i
]
=
gPlayers
[
j
]
->
score
;
}
}
gSorting
[
i
]
=
gPlayers
[
j
]
->
score
;
}
}
for
(
int
i
=
0
;
i
<
gPlayers
.
size
();
i
++
){
//For MVP-purposes no scores can be
for
(
int
k
=
0
;
k
<
gPlayers
.
size
();
k
++
){
//For MVP-purposes no scores can be
//identical
cout
<<
temp
[
i
]
<<
"
\t
"
;
for
(
int
j
=
0
;
j
<
gPlayers
.
size
();
i
++
){
if
(
gPlayers
[
j
]
->
score
==
temp
[
i
]){
cout
<<
gSorting
[
k
]
<<
"
\t
"
;
//Prints result
for
(
int
j
=
0
;
j
<
gPlayers
.
size
();
j
++
){
if
(
gPlayers
[
j
]
->
score
==
gSorting
[
k
]){
cout
<<
gPlayers
[
j
]
->
name
;
}
cout
<<
"
\n
"
;
...
...
@@ -595,3 +592,13 @@ void amntTables(){
cout
<<
"How many tables do you have?
\n
"
;
gTables
=
lesInt
(
"Tables:"
,
1
,
200
);
}
void
viewResults
(){
for
(
int
i
=
0
;
i
<
gPlayers
.
size
();
i
++
){
gPlayers
[
i
]
->
calculateScore
();
//Calculates score for every player
for
(
int
i
=
0
;
i
<
gPlayers
.
size
();
i
++
){
gPlayers
->
viewResults
(
i
);}
}
\ No newline at end of file
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