对于一个练习,我有一个枚举(由老师设置),如下所示:
enum class Weapon(name: String, damage: Int) {
SWORD("Sword", 12),
AXE("Axe", 13),
BOW("Bow", 14)
}
The weapon will be an attribute of a data class Player
But once I set player.weapon = Weapon.SWORD
How do i access to the name
or damage
of the weapon
?
我在互联网上寻找答案,但没有找到任何带有两个"参数"的枚举(不知道如何称呼它),所以我开始怀疑这个枚举是否可行.
Thanks guys