Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tok-chef
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
Antoine HAZEBROUCK
tok-chef
Commits
0b4b8797
Commit
0b4b8797
authored
Sep 14, 2024
by
Antoine Hazebrouck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
immutable chef incr etoiles
parent
df3b1ed0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
15 deletions
+19
-15
FileConcours.java
src/main/java/imt/concours/FileConcours.java
+6
-3
Chef.java
src/main/java/imt/personnes/Chef.java
+6
-7
ConcoursTest.java
src/test/java/imt/concours/ConcoursTest.java
+1
-1
ChefTest.java
src/test/java/imt/personnes/ChefTest.java
+6
-4
No files found.
src/main/java/imt/concours/FileConcours.java
View file @
0b4b8797
...
...
@@ -32,9 +32,12 @@ public class FileConcours {
// true is ca a marché, false si le concours actuel est pas bien fini
public
Optional
<
Chef
>
passerAuConcoursSuivant
()
{
if
(
concoursActuel
().
estTermine
())
{
Concours
current
=
concours
.
poll
();
concoursTermines
.
add
(
current
);
return
Optional
.
of
(
current
.
classement
().
get
(
0
).
getChef
());
Concours
concoursActuel
=
concours
.
poll
();
concoursTermines
.
add
(
concoursActuel
);
Chef
gagnant
=
concoursActuel
.
classement
().
get
(
0
).
getChef
().
incrementVictoires
();
return
Optional
.
of
(
gagnant
);
}
else
{
return
Optional
.
empty
();
}
...
...
src/main/java/imt/personnes/Chef.java
View file @
0b4b8797
...
...
@@ -2,28 +2,24 @@ package imt.personnes;
import
java.util.List
;
import
java.util.Set
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
imt.ingredients.Plat
;
import
lombok.AccessLevel
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.ToString
;
@ToString
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
Chef
extends
Person
{
@Getter
(
value
=
AccessLevel
.
NONE
)
private
final
AtomicInteger
victoires
;
private
final
int
victoires
;
private
final
Specialite
specialite
;
private
final
Set
<
Plat
>
plats
;
public
Chef
(
int
id
,
String
nom
,
String
prenom
,
String
telephone
,
Genre
genre
,
int
victoires
,
Specialite
specialite
,
Set
<
Plat
>
plats
)
{
super
(
id
,
nom
,
prenom
,
telephone
,
genre
);
this
.
victoires
=
new
AtomicInteger
(
victoires
)
;
this
.
victoires
=
victoires
;
this
.
specialite
=
specialite
;
this
.
plats
=
plats
;
}
...
...
@@ -36,7 +32,6 @@ public class Chef extends Person {
}
public
int
getEtoiles
()
{
int
victoires
=
this
.
victoires
.
intValue
();
if
(
victoires
<
1
)
{
return
0
;
}
else
if
(
victoires
<
3
)
{
...
...
@@ -47,4 +42,8 @@ public class Chef extends Person {
return
3
;
}
}
public
Chef
incrementVictoires
()
{
return
new
Chef
(
getId
(),
getNom
(),
getPrenom
(),
getTelephone
(),
getGenre
(),
getVictoires
()
+
1
,
getSpecialite
(),
getPlats
());
}
}
src/test/java/imt/concours/ConcoursTest.java
View file @
0b4b8797
...
...
@@ -23,7 +23,7 @@ public class ConcoursTest {
public
static
Jury
JURY_2
=
new
Jury
(
2
,
"nom2"
,
"prenom2"
,
"06"
,
Genre
.
HOMME
);
public
static
Jury
JURY_3
=
new
Jury
(
3
,
"nom3"
,
"prenom3"
,
"06"
,
Genre
.
HOMME
);
public
static
Chef
CHEF_1
=
new
Chef
(
1
,
"chef1"
,
"prenomchef1"
,
"07"
,
Genre
.
HOMME
,
2
,
Specialite
.
PATISSIER
,
public
static
Chef
CHEF_1
=
new
Chef
(
1
,
"chef1"
,
"prenomchef1"
,
"07"
,
Genre
.
HOMME
,
0
,
Specialite
.
PATISSIER
,
Set
.
of
(
new
Plat
(
1
,
"plat1"
,
new
Ingredient
[]
{})));
public
static
Chef
chef2
=
new
Chef
(
2
,
"chef2"
,
"prenomchef2"
,
"07"
,
Genre
.
HOMME
,
2
,
Specialite
.
PATISSIER
,
Set
.
of
(
new
Plat
(
2
,
"plat2"
,
new
Ingredient
[]
{})));
...
...
src/test/java/imt/personnes/ChefTest.java
View file @
0b4b8797
...
...
@@ -47,14 +47,16 @@ public class ChefTest {
Concours
CONCOURS_1
=
CONCOURS_1
();
Concours
CONCOURS_2
=
CONCOURS_2
();
FileConcours
fileConcours
=
new
FileConcours
(
CONCOURS_1
,
CONCOURS_2
,
CONCOURS_3
());
forcerLaFinDuConcours
(
CONCOURS_1
);
assertThat
(
CHEF_1
.
getEtoiles
()).
isZero
();
Chef
gagnant
=
fileConcours
.
passerAuConcoursSuivant
().
get
();
// assertThat(gagnant).isEqualTo(CHEF_1);
// assertThat(CHEF_1.getEtoiles()).isEqualTo(1);
// TODO
assertThat
(
false
).
isTrue
();
assertThat
(
gagnant
.
getId
()).
isEqualTo
(
CHEF_1
.
getId
());
assertThat
(
gagnant
.
getEtoiles
()).
isOne
();
}
@Test
...
...
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