enum
s синтаксически действуют как обычные классы, поэтому вы можете иметь поля, методы и конструкторы.
Разница в том, что вы указываете экземпляры класса во время объявления enum.Эти экземпляры создаются jvm и не могут быть созданы любым другим способом.
Это, вероятно, то, что вы ищете:
public enum Items {
//Fields
String name;
AttackSpeed attackSpeed;
//constructor:
Items(String name, AttackSpeed attkSpd) {
this.name = name;
this.attackSpeed = attkSpd;
}
//methods:
public String getName() {
return name;
}
//listing the instances and calling the constructor:
StarterBow ("Starter Bow", AttackSpeed.SLOW),
AdvancedBow ("Advanced Bow", AttackSpeed.MEDIUM),
GoldenBow ("Golden Bow", AttackSpeed.FAST);
}