projet-genie-logiciel-systeme/runtime-workspace/fr.n7.game.examples/src-gen/Connaissance.java
2022-01-18 19:49:37 +01:00

32 lines
853 B
Java

import java.util.List;
public class Connaissance {
String nom;
Condition visible;
List<Description> descriptions;
public Connaissance(
String nom,
Condition visible,
List<Description> descriptions) {
this.nom = nom;
this.visible = visible;
this.descriptions = descriptions;
}
@Override
public String toString() {
for (Description d : this.descriptions) {
if (d.condition.evaluer()) {
return this.nom + " (" + d + ")";
}
}
return "(no description)";
}
public static Connaissance search(List<Connaissance> list, String name) {
return list.stream().filter(o -> o.nom.equals(name)).findFirst()
.orElseThrow(() -> new IllegalArgumentException("No data found"));
}
}