Commit 48edc0fe authored by Pronier Julien's avatar Pronier Julien

Modif consigne et ToString des ingrédients

parent c5fd52a4
Pipeline #2882 canceled with stages
......@@ -16,10 +16,13 @@ public class Application {
Ingredient ingredient1 = new Legume(1,"Oignons",120,false);
Ingredient ingredient2 = new Legume(2,"Patate",120,false);
Ingredient ingredient3 = new ViandePoisson(3,"Poulet",120,12);
ingredient1.setConsigne(Consigne.CUIT);
ingredient2.setConsigne(Consigne.CUIT);
ingredient3.setConsigne(Consigne.CUIT);
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);
......
......@@ -27,6 +27,6 @@ public class Autre extends Ingredient {
}
public String toString() {
return "Autre [calories=" + calories + ", bio=" + bio + ", idIngredient=" + getIdIngredient() + ", nomIngredient=" + getNomIngredient() + "]";
return super.toString() + " Autre [calories=" + calories + ", bio=" + bio + "]";
}
}
......@@ -17,6 +17,6 @@ public class Epice extends Ingredient{
}
public String toString() {
return "Epice [bio=" + bio + ", idIngredient=" + getIdIngredient() + ", nomIngredient=" + getNomIngredient() + "]";
return super.toString() + " Epice [bio=" + bio + "]";
}
}
......@@ -4,13 +4,13 @@ public class Ingredient {
private int idIngredient;
private String nomIngredient;
private int quantité;
private Consigne consigne;
private Consigne[] consignes;
public Ingredient(int idIngredient, String nomIngredient) {
this.idIngredient = idIngredient;
this.nomIngredient = nomIngredient;
this.quantité = 0;
this.consigne = null;
this.consignes = null;
}
public int getIdIngredient() {
......@@ -37,15 +37,19 @@ public class Ingredient {
this.quantité = quantité;
}
public Consigne getConsigne() {
return consigne;
public Consigne[] getConsignes() {
return consignes;
}
public void setConsigne(Consigne consigne) {
this.consigne = consigne;
public void setConsignes(Consigne[] consignes) {
this.consignes = consignes;
}
public String toString() {
return "Ingredient [idIngredient=" + idIngredient + ", nomIngredient=" + nomIngredient + "]";
String strConsigne = "";
for (int i = 0; i < consignes.length; i++) {
strConsigne += consignes[i].toString()+", ";
}
return "Ingredient [idIngredient=" + idIngredient + ", nomIngredient=" + nomIngredient + ", Consignes=" + strConsigne + "]";
}
}
......@@ -27,6 +27,6 @@ public class Legume extends Ingredient{
}
public String toString() {
return "Legume [calories=" + calories + ", bio=" + bio + ", idIngredient=" + getIdIngredient() + ", nomIngredient=" + getNomIngredient() + "]";
return super.toString() + " Legume [calories=" + calories + ", bio=" + bio + "]";
}
}
......@@ -26,5 +26,8 @@ public class ViandePoisson extends Ingredient{
this.gras = gras;
}
public String toString() {
return super.toString() + " Viande/Poisson [calories=" + calories + ", gras=" + gras + "]";
}
}
\ No newline at end of file
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