Commit 7d1e0678 authored by Antoine Hazebrouck's avatar Antoine Hazebrouck

un coucours marche

parent 554eb658
......@@ -3,9 +3,9 @@ package imt;
public class Application {
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);
// 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);
// System.out.println(padawan);
}
}
package imt;
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
......@@ -10,10 +12,13 @@ import lombok.ToString;
public class Chef extends Person {
private final int etoiles;
private final Specialite specialite;
private final Set<Plat> plats;
public Chef(int id, String nom, String prenom, String telephone, Genre genre, int etoiles, Specialite specialite) {
public Chef(int id, String nom, String prenom, String telephone, Genre genre, int etoiles, Specialite specialite,
Set<Plat> plats) {
super(id, nom, prenom, telephone, genre);
this.etoiles = etoiles;
this.specialite = specialite;
this.plats = plats;
}
}
package imt;
import java.util.Optional;
import java.util.Set;
import lombok.Data;
@Data
public class Concours {
private final Jury jury1;
private final Jury jury2;
private final Jury jury3;
private final Set<Proposition> propositions; // minimun 5
public Concours(Jury jury1, Jury jury2, Jury jury3, Set<Proposition> propositions) {
this.jury1 = jury1;
this.jury2 = jury2;
this.jury3 = jury3;
for (Proposition proposition : propositions) {
if (proposition.getChef().getPlats().contains(proposition.getPlatPropose()) == false) {
throw new IllegalArgumentException();
}
}
if (propositions.size() != 5) {
throw new IllegalArgumentException();
} else {
this.propositions = propositions;
}
}
public boolean estTermine() {
return propositions.stream()
.allMatch(proposition -> proposition.getNote().isPresent());
}
public void noter(Proposition proposition, int note) {
for (Proposition propositionLoop : propositions) {
if (propositionLoop.equals(proposition)) {
propositionLoop.setNote(Optional.of(note));
}
}
}
}
// package imt;
package imt;
// import lombok.Data;
// import lombok.EqualsAndHashCode;
public class Jury extends Person {
// @EqualsAndHashCode(callSuper = true)
// @Data
// public class Jury extends Person {
// // private final int TODO faire les jurys
// public Jury() {
// super(null, null, null, null, null);
// }
// }
// TODO finir quand les Jurys sont finito
\ No newline at end of file
public Jury(int id, String nom, String prenom, String telephone, Genre genre) {
super(id, nom, prenom, telephone, genre);
//TODO Auto-generated constructor stub
}
}
\ No newline at end of file
package imt;
import lombok.Data;
@Data
public class Plat {
private final String something;
public Plat(String something) {
this.something = something;
}
public Plat() {
something = "";
}
}
package imt;
import java.util.Optional;
import lombok.Data;
@Data
public class Proposition {
private final Plat platPropose;
private final Chef chef;
private Optional<Integer> note;
public Proposition(Plat platPropose, Chef chef) {
this.platPropose = platPropose;
this.chef = chef;
this.note = Optional.empty();
}
}
package imt;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Set;
import org.junit.jupiter.api.Test;
public class ConcoursTest {
Jury jury1 = new Jury(1, "nom1", "prenom1", "06", Genre.HOMME);
Jury jury2 = new Jury(2, "nom2", "prenom2", "06", Genre.HOMME);
Jury jury3 = new Jury(3, "nom3", "prenom3", "06", Genre.HOMME);
Chef chef1 = new Chef(1, "chef1", "prenomchef1", "07", Genre.HOMME, 2, Specialite.PATISSIER,
Set.of(new Plat("plat1")));
Chef chef2 = new Chef(2, "chef2", "prenomchef2", "07", Genre.HOMME, 2, Specialite.PATISSIER,
Set.of(new Plat("plat2")));
Chef chef3 = new Chef(3, "chef3", "prenomchef3", "07", Genre.HOMME, 2, Specialite.PATISSIER,
Set.of(new Plat("plat3")));
Chef chef4 = new Chef(4, "chef4", "prenomchef4", "07", Genre.HOMME, 2, Specialite.PATISSIER,
Set.of(new Plat("plat4")));
Chef chef5 = new Chef(5, "chef5", "prenomchef5", "07", Genre.HOMME, 2, Specialite.PATISSIER,
Set.of(new Plat("plat5")));
@Test
void concours_trois_jurys_cinq_chefs() {
var propositions = Set.of(
new Proposition(new Plat("plat1"), chef1),
new Proposition(new Plat("plat2"), chef2),
new Proposition(new Plat("plat3"), chef3),
new Proposition(new Plat("plat4"), chef4));
assertThrows(IllegalArgumentException.class, () -> new Concours(jury1, jury2, jury3, propositions));
}
@Test
void les_chefs_proposent_un_plat_qu_ils_savent_faire() {
var propositions = Set.of(
new Proposition(new Plat("plat1"), chef1),
new Proposition(new Plat("plat2"), chef2),
new Proposition(new Plat("plat3"), chef3),
new Proposition(new Plat("plat4"), chef4),
new Proposition(new Plat("je sais pas faire donc exception"), chef5));
assertThrows(IllegalArgumentException.class, () -> new Concours(jury1, jury2, jury3, propositions));
}
@Test
void fin_du_concours() {
Proposition proposition1 = new Proposition(new Plat("plat1"), chef1);
Proposition proposition2 = new Proposition(new Plat("plat2"), chef2);
Proposition proposition3 = new Proposition(new Plat("plat3"), chef3);
Proposition proposition4 = new Proposition(new Plat("plat4"), chef4);
Proposition proposition5 = new Proposition(new Plat("plat5"), chef5);
Concours concours = new Concours(jury1, jury2, jury3, Set.of(
proposition1,
proposition2,
proposition3,
proposition4,
proposition5
));
assertEquals(false, concours.estTermine());
concours.noter(proposition1, 10);
concours.noter(proposition2, 3);
concours.noter(proposition3, 8);
concours.noter(proposition4, 9);
concours.noter(proposition5, 18);
assertEquals(true, concours.estTermine());
}
}
package imt;
import org.junit.jupiter.api.Test;
public class FileConcoursTest {
@Test
void fileDeConcours() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment