找不到变量类型字符的符号位置

时间:2016-01-24 18:24:13

标签: java symbols

所以我一直在尝试使用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。任何想法如何让这个工作?

1 个答案:

答案 0 :(得分:0)

Java认为Сharacter - 是基本类型 java.lang.Character ,它没有getHealth()方法。 替换

Run run = new Run(smallPotion.Name + "(" + smallPotion.AffectValue + ")\r\n");
run.Foreground = Brushes.Green;
tbPotionInfo.Inlines.Add(run);   

run = new Run(mediumPotion.Name + "(" + mediumPotion.AffectValue + ")\r\n");
run.Foreground = Brushes.Blue;
tbPotionInfo.Inlines.Add(run);        
...

public int Heal(Character teammate){
相关问题