使用 IntelliJ ultimate 时出错“预期方法调用”
Error using IntelliJ ultimate " Method Call Expected"
这个方法在我的父 class 它被命名为 "getEasterAttack" 我试图在另一个 class 中调用它,它是 ninjaGetDamageRecieved 但是错误 "Method Call Expected" 一直存在接下来。是因为我的方法签名中的接收没有要求 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());
}
damage
不是方法,而是 int
值。因此 Intellij 会警告您,将它用作方法是行不通的:
damage(getEasterAttack())
不适用于 int
。
这个方法在我的父 class 它被命名为 "getEasterAttack" 我试图在另一个 class 中调用它,它是 ninjaGetDamageRecieved 但是错误 "Method Call Expected" 一直存在接下来。是因为我的方法签名中的接收没有要求 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());
}
damage
不是方法,而是 int
值。因此 Intellij 会警告您,将它用作方法是行不通的:
damage(getEasterAttack())
不适用于 int
。