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
15f0bad4
Commit
15f0bad4
authored
Sep 13, 2024
by
Antoine Hazebrouck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plats par calories
parent
3dd8e673
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
30 deletions
+51
-30
Application.java
src/main/java/imt/Application.java
+0
-23
Plat.java
src/main/java/imt/ingredients/Plat.java
+6
-0
Chef.java
src/main/java/imt/personnes/Chef.java
+8
-0
PlatTest.java
src/test/java/imt/ingredients/PlatTest.java
+9
-0
ChefTest.java
src/test/java/imt/personnes/ChefTest.java
+28
-7
No files found.
src/main/java/imt/Application.java
View file @
15f0bad4
package
imt
;
package
imt
;
import
imt.ingredients.Consigne
;
import
imt.ingredients.Ingredient
;
import
imt.ingredients.Legume
;
import
imt.ingredients.Plat
;
import
imt.ingredients.ViandePoisson
;
public
class
Application
{
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// var chef = new Chef(1, "Caca", "Pipi", "DQSQFQSF", Genre.HOMME, 3, Specialite.CUISINIER);
// var padawan = new Padawan(1, "Hazebrouck", "Antoine", "06 51 73 08 05", Genre.HOMME, chef);
// System.out.println(padawan);
Ingredient
ingredient1
=
new
Legume
(
1
,
"Oignons"
,
120
,
false
);
Ingredient
ingredient2
=
new
Legume
(
2
,
"Patate"
,
120
,
false
);
Ingredient
ingredient3
=
new
ViandePoisson
(
3
,
"Poulet"
,
120
,
12
);
Consigne
[]
consignes
=
Consigne
.
values
();
Ingredient
[]
ingredients
=
{
ingredient1
,
ingredient2
,
ingredient3
};
for
(
int
i
=
0
;
i
<=
2
;
i
++){
ingredients
[
i
].
setConsignes
(
consignes
);
}
System
.
out
.
println
(
ingredient1
);
Plat
plat
=
new
Plat
(
1
,
"Oignon Poulet patate"
,
ingredients
);
System
.
out
.
println
(
plat
);
}
}
}
}
src/main/java/imt/ingredients/Plat.java
View file @
15f0bad4
...
@@ -54,4 +54,10 @@ public class Plat {
...
@@ -54,4 +54,10 @@ public class Plat {
.
allMatch
(
ingredient
->
ingredient
.
isBio
());
.
allMatch
(
ingredient
->
ingredient
.
isBio
());
}
}
public
int
getCalories
()
{
return
Stream
.
of
(
ingredients
)
.
mapToInt
(
ingredient
->
ingredient
.
getCalories
())
.
sum
();
}
}
}
src/main/java/imt/personnes/Chef.java
View file @
15f0bad4
package
imt
.
personnes
;
package
imt
.
personnes
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
imt.ingredients.Plat
;
import
imt.ingredients.Plat
;
...
@@ -22,4 +23,11 @@ public class Chef extends Person {
...
@@ -22,4 +23,11 @@ public class Chef extends Person {
this
.
specialite
=
specialite
;
this
.
specialite
=
specialite
;
this
.
plats
=
plats
;
this
.
plats
=
plats
;
}
}
public
List
<
Plat
>
getPlatsParCalories
()
{
return
plats
.
stream
()
.
sorted
((
left
,
right
)
->
{
return
Integer
.
valueOf
(
left
.
getCalories
()).
compareTo
(
Integer
.
valueOf
(
right
.
getCalories
()));
}).
toList
();
}
}
}
src/test/java/imt/ingredients/PlatTest.java
View file @
15f0bad4
...
@@ -22,4 +22,13 @@ public class PlatTest {
...
@@ -22,4 +22,13 @@ public class PlatTest {
assertThat
(
platNonBio
.
isBio
()).
isFalse
();
assertThat
(
platNonBio
.
isBio
()).
isFalse
();
}
}
@Test
void
calories_d_un_plat
()
{
Plat
platBio
=
new
Plat
(
1
,
"plat1"
,
new
Ingredient
[]
{
STEAK
,
OIGNON
});
assertThat
(
platBio
.
getCalories
()).
isEqualTo
(
STEAK
.
getCalories
()
+
OIGNON
.
getCalories
());
}
}
}
src/test/java/imt/personnes/ChefTest.java
View file @
15f0bad4
package
imt
.
personnes
;
package
imt
.
personnes
;
import
static
imt
.
ingredients
.
IngredientTest
.
AUTRE
;
import
static
imt
.
ingredients
.
IngredientTest
.
OIGNON
;
import
static
imt
.
ingredients
.
IngredientTest
.
STEAK
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
java.util.List
;
import
java.util.Set
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
imt.ingredients.Ingredient
;
import
imt.ingredients.Ingredient
;
import
imt.ingredients.Legume
;
import
imt.ingredients.Plat
;
import
imt.ingredients.Plat
;
public
class
ChefTest
{
public
class
ChefTest
{
// @Test
@Test
// void plat_connus_d_un_chef_par_calories() {
void
plat_connus_d_un_chef_par_calories
()
{
// Plat plat1 = new Plat(1, "plat1", new Ingredient[] {
Plat
plat1
=
new
Plat
(
1
,
"plat1"
,
new
Ingredient
[]
{
// new Legume(1, "poivron", 10, true);
OIGNON
,
STEAK
// });
});
// }
Plat
plat2
=
new
Plat
(
2
,
"plat2"
,
new
Ingredient
[]
{
OIGNON
,
AUTRE
});
Plat
plat3
=
new
Plat
(
3
,
"plat3"
,
new
Ingredient
[]
{
STEAK
,
AUTRE
});
Chef
chef
=
new
Chef
(
1
,
"mister"
,
"toto"
,
"06 ."
,
Genre
.
HOMME
,
2
,
Specialite
.
CUISINIER
,
Set
.
of
(
plat1
,
plat2
,
plat3
));
assertThat
(
chef
.
getPlatsParCalories
()).
isEqualTo
(
List
.
of
(
plat1
,
plat3
,
plat2
));
}
}
}
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