这是我班级的早期构建:
public class Player {
public enum Tech {
NONE(EnumSet.noneOf(Tech.class)),
VEGETATION(EnumSet.of(NONE)),
LIVESTOCK(EnumSet.of(NONE)),
STRAWBERRIES(EnumSet.of(VEGETATION)),
BIODOME(EnumSet.of(STRAWBERRIES)),
BIOMASS(EnumSet.of(VEGETATION, LIVESTOCK));
private final Set<Tech> prerequisites;
Tech(Set<Tech> prerequisites) {
this.prerequisites = prerequisites;
}
}
private Set<Tech> techsKnown;
public Player() {
techsKnown = EnumSet.of(Tech.NONE);
}
}
我希望NONE有一个空集。什么是最好的方式?