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 { ...@@ -16,10 +16,13 @@ public class Application {
Ingredient ingredient1 = new Legume(1,"Oignons",120,false); Ingredient ingredient1 = new Legume(1,"Oignons",120,false);
Ingredient ingredient2 = new Legume(2,"Patate",120,false); Ingredient ingredient2 = new Legume(2,"Patate",120,false);
Ingredient ingredient3 = new ViandePoisson(3,"Poulet",120,12); Ingredient ingredient3 = new ViandePoisson(3,"Poulet",120,12);
ingredient1.setConsigne(Consigne.CUIT); Consigne[] consignes = Consigne.values();
ingredient2.setConsigne(Consigne.CUIT);
ingredient3.setConsigne(Consigne.CUIT);
Ingredient[] ingredients = {ingredient1, ingredient2, ingredient3}; 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); Plat plat = new Plat(1,"Oignon Poulet patate", ingredients);
System.out.println(plat); System.out.println(plat);
......
...@@ -27,6 +27,6 @@ public class Autre extends Ingredient { ...@@ -27,6 +27,6 @@ public class Autre extends Ingredient {
} }
public String toString() { 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{ ...@@ -17,6 +17,6 @@ public class Epice extends Ingredient{
} }
public String toString() { public String toString() {
return "Epice [bio=" + bio + ", idIngredient=" + getIdIngredient() + ", nomIngredient=" + getNomIngredient() + "]"; return super.toString() + " Epice [bio=" + bio + "]";
} }
} }
...@@ -4,13 +4,13 @@ public class Ingredient { ...@@ -4,13 +4,13 @@ public class Ingredient {
private int idIngredient; private int idIngredient;
private String nomIngredient; private String nomIngredient;
private int quantité; private int quantité;
private Consigne consigne; private Consigne[] consignes;
public Ingredient(int idIngredient, String nomIngredient) { public Ingredient(int idIngredient, String nomIngredient) {
this.idIngredient = idIngredient; this.idIngredient = idIngredient;
this.nomIngredient = nomIngredient; this.nomIngredient = nomIngredient;
this.quantité = 0; this.quantité = 0;
this.consigne = null; this.consignes = null;
} }
public int getIdIngredient() { public int getIdIngredient() {
...@@ -37,15 +37,19 @@ public class Ingredient { ...@@ -37,15 +37,19 @@ public class Ingredient {
this.quantité = quantité; this.quantité = quantité;
} }
public Consigne getConsigne() { public Consigne[] getConsignes() {
return consigne; return consignes;
} }
public void setConsigne(Consigne consigne) { public void setConsignes(Consigne[] consignes) {
this.consigne = consigne; this.consignes = consignes;
} }
public String toString() { 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{ ...@@ -27,6 +27,6 @@ public class Legume extends Ingredient{
} }
public String toString() { 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{ ...@@ -26,5 +26,8 @@ public class ViandePoisson extends Ingredient{
this.gras = gras; 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