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
dcd16e19
Commit
dcd16e19
authored
3 years ago
by
TheHresvelgian
Browse files
Options
Downloads
Patches
Plain Diff
Organizing code
parent
2c31dedc
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/kode/Tournament.cpp
+48
-1
48 additions, 1 deletion
src/kode/Tournament.cpp
src/kode/Tournament.h
+4
-2
4 additions, 2 deletions
src/kode/Tournament.h
src/kode/checkmate.cpp
+0
-38
0 additions, 38 deletions
src/kode/checkmate.cpp
with
52 additions
and
41 deletions
src/kode/Tournament.cpp
+
48
−
1
View file @
dcd16e19
...
...
@@ -15,15 +15,62 @@
using
namespace
std
;
extern
vector
<
Tournament
*>
gTournaments
;
extern
vector
<
Player
*>
playerList
;
extern
vector
<
Player
*>
sortedRankings
;
void
Tournament
::
startNewTournament
()
{
char
answer
;
do
{
cout
<<
endl
<<
"Are you certain you wish to start a new tournament?"
<<
"This will delete all existing tournament data, including the player list."
;
answer
=
lesChar
(
" Y/N
\n
"
);
answer
=
tolower
(
answer
);
}
while
(
answer
!=
'y'
&&
answer
!=
'n'
);
if
(
answer
==
'n'
)
{
return
;
}
playerList
.
clear
();
sortedRankings
.
clear
();
gTournaments
.
clear
();
Tournament
*
newTournament
;
newTournament
=
new
Tournament
;
newTournament
->
nrOfTables
=
lesInt
(
"
\n
How many tables should the tournament have?
\n
"
,
1
,
1000
);
newTournament
->
currentRound
=
0
;
newTournament
->
nrOfRounds
=
lesInt
(
"
\n
How many rounds should the tournament have?
\n
"
,
1
,
20
);
gTournaments
.
push_back
(
newTournament
);
}
void
Tournament
::
enterResults
()
{
}
void
Tournament
::
nextRound
()
void
Tournament
::
printTables
()
{
if
(
canStartRound
()
==
false
)
{
cout
<<
endl
<<
"There number of tables does not correspond to the amount of players,"
<<
" please add or remove players so that there is exactly two players per table."
<<
endl
;
return
;
}
}
bool
Tournament
::
canStartRound
()
{
if
(
playerList
.
size
()
==
nrOfTables
*
2
)
{
return
true
;
}
else
{
return
false
;
}
}
void
Tournament
::
endTournament
()
...
...
This diff is collapsed.
Click to expand it.
src/kode/Tournament.h
+
4
−
2
View file @
dcd16e19
...
...
@@ -28,9 +28,11 @@ class Tournament
vector
<
int
>
white
;
vector
<
int
>
black
;
virtual
void
startNewTournament
();
//
-
virtual
void
nextRound
();
//-
virtual
void
startNewTournament
();
//
+
virtual
void
enterResults
();
//-
virtual
void
endTournament
();
//-
virtual
void
printTables
();
//-
bool
canStartRound
();
//
void
writeToFileTournament
(
ofstream
&
out
);
//-
void
readFromFileTournaments
(
ifstream
&
in
);
//-
...
...
This diff is collapsed.
Click to expand it.
src/kode/checkmate.cpp
+
0
−
38
View file @
dcd16e19
...
...
@@ -213,35 +213,6 @@ void enterResults()
}
}
/**
* Create a new tournament, with black and white players and what table they're playing at
* @see writeTournament()
* @see fillTableArray()
*/
void
newTournament
()
{
if
(
gRounds
==
0
){
cout
<<
"Table:
\t
Player 1:
\t
Player 2:
\n
"
;
for
(
int
i
=
0
;
i
<
gPlayers
.
size
();
i
+
2
){
cout
<<
i
+
1
<<
"
\t
"
<<
gPlayers
[
i
]
->
returnName
()
<<
"
\t
"
<<
gPlayers
[
i
+
1
]
->
returnName
()
<<
"
\n
"
;
}
gRounds
++
;
}
else
{
cout
<<
"Table:
\t
Player 1:
\t
Player 2:
\n
"
;
for
(
int
i
=
0
;
i
<
gPlayers
.
size
();
i
++
){
for
(
int
j
=
1
;
j
<
gPlayers
.
size
();
j
++
){
// gPlayers[i]->playedBefore[j];
}
}
gRounds
++
;
}
}
/**
* edit info about a player
*
...
...
@@ -317,12 +288,3 @@ void skrivMeny()
<<
"
\t
6 - View results
\n
"
<<
"
\t
Q - Quit
\n\n
"
;
}
/**
* Asks user for number of tables
*
*/
void
amntTables
(){
cout
<<
"How many tables do you have?
\n
"
;
gTables
=
lesInt
(
"Tables:"
,
1
,
200
);
}
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