如何在useSkill
方法中引用hit_point
?我现在所拥有的根本没有增加hit_point
。
public int hit_point() {
int total_power = this.power + this.weapon.getPower();
return total_power;
}
//------------------------------------------------------why isn't this increasing the hit point at all?
public int useSkill() {
this.mp=this.mp-1;
this.skill--;
return hit_point() +30;
}
public int getSkill() {
return skill;
}
返回值时,方法不会存储返回值,除非您告诉程序按如下方式存储值:int totalHitPoint = useSkill()
.然后useSkill()
不仅会增加已经计算的总生命值,而且还会存储在您可以按需使用的变量中。