2
這是我目前枚舉類:如何在Java中使用單獨的枚舉類引用靜態類?
public enum BuildingType {
MINER("Miner", "A basic slave." (*, Miner (separate class)*)), FARM("Farm", "Old Macdonald's Crib."), BAKERY("Bakery", "Best Cookies in Town!"), FACTORY("Factory", "Highest Quality Memes in town!"), QUARRY("Quarry", "Let's get drilling!");
private String name;
private String description;
//private Class clazz;
BuildingType(String name, String description (* Possible to put Class clazz reference here? *)) {
this.name = name;
this.description = description;
//this.clazz = clazz
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public Class getReferencedClass() {
//Return referenced "clazz" above
}
}
由於把評價和(*),是否有可能引用靜態類枚舉裏面,所以我可以通過只引用更改類的內部靜態值建築類型?
例如
BuildingType.MINER.getReferencedClass.setCookiesPerSecond(4);
感謝所有,
雅科:)