【发布时间】:2018-10-14 18:48:23
【问题描述】:
我正在完成教科书上的任务。我不能从同一个类中调用“poisonAttack”方法。如果有人能给我反馈,将不胜感激。
public class PoisonMatango extends Matango {
PoisonMatango pm = new PoisonMatango ('A');
public PoisonMatango ( char suffix) {
super(suffix);
}
// The method I am trying call.
public void poisonAttack(Hero h) {
super.attack(h);
int poisonCount = 5;
if ( poisonCount >=0 ) {
System.out.println("The enemy had spread poisonous pollons");
int pollenDamage = h.hp / 5;
h.hp-= pollenDamage;
System.out.println("Hero has received " + pollenDamage + "damage from " );
poisonCount --;
}else
{
System.out.println("No additional attack were made since poisonCount= 0");
}}
}
【问题讨论】:
-
instance.methodName([parameter1][, parameter2][, ... parameterN]);...但这应该在您的书中解释或更改...
标签: java