【发布时间】:2016-04-30 23:55:21
【问题描述】:
所以我一直在尝试使用 java 制作文本 rpg 游戏,我一直遇到这个错误
Mage.java:12: error: cannot find symbol
teammate.setHealth( teammate.getHealth() + 25 );
^
symbol: method getHealth()
location: variable teammate of type Character
1 error
我的代码是
public int Heal(Character teammate){
// Heals a target
mana -= 20;
teammate.setHealth( teammate.getHealth() + 25 );
}
我在另一个类文件中定义了 getHealth 和 setHealth。任何想法如何让它发挥作用?
【问题讨论】:
-
Character是**java Character**类还是你做的costum类?