Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java_Yams
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GPSE
4A
Java_Yams
Commits
9a85421a
Commit
9a85421a
authored
Jul 24, 2021
by
Weber Rodolphe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete SheetPlayer.java
parent
e15d74a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
129 deletions
+0
-129
SheetPlayer.java
src/SheetPlayer.java
+0
-129
No files found.
src/SheetPlayer.java
deleted
100644 → 0
View file @
e15d74a7
/**
* @file SheeetPlayer.java
* @author WEBER rodolphe <rodolphe.weber@univ-orleans.fr>
* @version 1.0
* @date 22/07/2021
*
* @section LICENSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @section DESCRIPTION
*
* This java file represents a java lab for the 4th year students of Polytech Orleans.
*/
import
java.util.Scanner
;
/**
* @brief manages the scoring sheet of the players
*/
public
class
SheetPlayer
{
private
final
String
LINE
=
"--------------------"
;
private
final
char
[]
FIG_INDEX
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
};
private
final
String
[]
FIG_NAME
={
"Brelan"
,
"Full"
,
"Carré"
,
"Petite Suite"
,
"Grande Suite"
,
"Yams"
,
"Chance"
};
private
String
playerName
;
/**< player name */
private
Integer
[]
scoring
=
new
Integer
[
13
];
/** scoring table */
private
int
round
;
/**< count the number of round */
//private int totalScore; /**< final player score */
private
char
[]
figureIndex
;
/**< letters indicating the figure type */
//private int subTotalScore; /**< all number score */
//private int bonus; /**< bonus score */
/**
* @brief constructor
* @param name
*/
SheetPlayer
(
String
name
){
this
.
playerName
=
name
;
for
(
int
idx
=
0
;
idx
<
scoring
.
length
;
idx
++){
scoring
[
idx
]=
null
;
}
figureIndex
=
FIG_INDEX
;
round
=
1
;
}
/**
* @brief print the formatted score
* @param score Integer
* @return String with '-' or score
*/
private
String
nullToMinus
(
Integer
score
){
return
(
score
==
null
?
"-"
:
score
.
toString
());
}
/**
* @brief compute the bonus
* @return 0 or 35
*/
private
int
bonus
(){
return
(
subTotalScore
()>=
63
)?
35
:
0
;
}
/**
* @brief compute the subtotal
* @return int
*/
private
int
subTotalScore
(){
Integer
total
=
0
;
for
(
int
idx
=
0
;
idx
<=
5
;
idx
++){
total
+=(
scoring
[
idx
]==
null
)?
0
:
scoring
[
idx
]
;
}
return
(
int
)
total
;
}
public
int
totalScore
()
{
Integer
total
=
subTotalScore
()+
bonus
();
for
(
int
idx
=
6
;
idx
<
13
;
idx
++){
total
+=(
scoring
[
idx
]==
null
)?
0
:
scoring
[
idx
]
;
}
return
(
int
)
total
;
}
/**
* @brief print the scoring sheet
*/
public
void
printScore
(){
System
.
out
.
println
(
LINE
);
System
.
out
.
println
(
"Player: "
+
playerName
+
" round: "
+
round
);
System
.
out
.
println
(
LINE
);
for
(
int
idx
=
1
;
idx
<=
6
;
idx
++){
System
.
out
.
println
(
"["
+
figureIndex
[
idx
-
1
]
+
"] sum of "
+
idx
+
" : "
+
nullToMinus
(
scoring
[
idx
-
1
]));
}
System
.
out
.
println
(
"----subTotal: "
+
subTotalScore
()
+
" => bonus : "
+
bonus
());
for
(
int
idx
=
7
;
idx
<=
13
;
idx
++){
System
.
out
.
println
(
"["
+
figureIndex
[
idx
-
1
]
+
"] "
+
FIG_NAME
[
idx
-
7
]
+
" : "
+
nullToMinus
(
scoring
[
idx
-
1
]));
}
System
.
out
.
println
(
"Total: "
+
totalScore
());
System
.
out
.
println
(
LINE
);
round
=(
round
%
3
)+
1
;
}
/**
* @brief put a cross
* @param index int figure index
*/
public
void
checkFigure
(
int
index
){
figureIndex
[
index
]=
'x'
;
}
public
int
askFigure
(
Scanner
sc
){
String
letter
;
do
{
System
.
out
.
println
(
"Indicates the figure you want to play (a,b ...m):"
);
letter
=
sc
.
nextLine
();
}
while
(!
String
.
valueOf
(
figureIndex
).
contains
(
letter
)
||
(
letter
==
String
.
valueOf
(
'x'
)));
return
String
.
valueOf
(
figureIndex
).
indexOf
(
letter
);
}
public
void
updateScoring
(
int
figureIndex
,
int
score
){
scoring
[
figureIndex
]=
score
;
this
.
figureIndex
[
figureIndex
]=
'x'
;
}
}
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