projet-genie-logiciel-systeme/enigme.java/Objet.java

30 lines
676 B
Java
Raw Normal View History

2021-12-01 19:55:46 +00:00
import java.util.List;
2021-11-30 19:49:01 +00:00
public class Objet {
String nom;
int taille;
Condition visible;
2021-12-01 19:55:46 +00:00
List<Description> descriptions;
2021-11-30 19:49:01 +00:00
public Objet(
String nom,
int taille,
Condition visible,
2021-12-01 19:55:46 +00:00
List<Description> descriptions) {
2021-11-30 19:49:01 +00:00
this.nom = nom;
this.taille = taille;
this.visible = visible;
2021-12-01 19:55:46 +00:00
this.descriptions = descriptions;
}
@Override
public String toString() {
for (Description d : this.descriptions) {
if (d.condition.evaluer()) {
2021-12-02 13:23:06 +00:00
return "(" + this.nom + ": " + d + ")";
2021-12-01 19:55:46 +00:00
}
}
2021-12-02 13:23:06 +00:00
return "(" + this.nom + ")";
2021-11-30 19:49:01 +00:00
}
}