使用IntelliJ ultimate“方法调用预期”时出错

时间:2016-07-17 22:36:35

标签: java class methods access-modifiers

此方法在我的父类中,它被命名为“getEasterAttack”我试图在另一个类ninjaGetDamageRecieved中调用它,如何错误“方法调用预期”不断出现。是因为我的方法签名中的receive不是要求int吗?还是因为我的访问修饰符?谢谢你的帮助

public  int getEasterAttack() {
    int shark = 100;
    int randnum = RandInt.randomInt(0, 125);

    if (randnum == getHealth()) {

    }
    return shark;
public int ninjaDamageReceivedCalculator(int rawDamageDealt) {
    int damage = 0;
    int protection = 0;
    if (getPlayerWeapon().equalsIgnoreCase("blade")) {
        damage = rawDamageDealt - (getRandomBladeRangeProtection() * getRandomAccuracyDamage());
    } else {
        damage = rawDamageDealt - (getRandomStarRangeProtection() * getRandomAccuracyDamage());
    }
    if (rawDamageDealt > protection + getForestProtection()) {
        damage = rawDamageDealt - (protection + getForestProtection());
    }
    this.removeHealth(damage);
    return damage(getEasterAttack());
}

1 个答案:

答案 0 :(得分:2)

damage不是方法,而是int值。因此Intellij警告你,使用它作为一种方法不会起作用:

damage(getEasterAttack())无法使用

int