my quick question is.
how would i be able to allow this method to return it's damageDelt value? i want to use this value to be able to subtract from another class field variable hitpoint value. how can i do this? as i would like this method to reduce the hitpoints from another objects hitpoints.
Thank you
package com.DavidLee.Programming;
public class Main {
public static void main(String[] args) {
new Main().railGunAttack();
System.out.println();
}
public void railGunAttack() {
int randomNumber = (int) (Math.random() * 100 + 1);
if (randomNumber > 0 && randomNumber < 50) {
int damageDelt = 2 * randomNumber;
System.out.println("Railgun did " + damageDelt + " Damage");
} else if (randomNumber > 50 && randomNumber < 80) {
int damageDelt = 4 * randomNumber;
System.out.println("Railgun did " + damageDelt + " Damage");
} else if (randomNumber > 80 && randomNumber < 100) {
int damageDelt = 50 - randomNumber;
System.out.println("Railgun did " + damageDelt + " Damage " + "Railgun projectiles glazed the target");
} else
System.out.println("Railgun missed target");
}
}
Aucun commentaire:
Enregistrer un commentaire