Java AP LESSON WORK QUESTION
1
·
int lowDamage; ·
int highDamage; ·
double
accuracy; The value of accuracy is a decimal
that expresses the percentage chance of getting a hit. So, if the accuracy is 0.8, then there will
be a hit 80% of the time and a miss 20% of the time. If a miss occurs, the function should
simply return -1. If a hit occurs, a random value
between lowDamage and highDamage
is returned. You should test your function with the
following main function: public static void main(String[] args) { int linkDamage = damage(4, 10,
0.6); if (linkDamage == -1)
else System.out.println("Link
did " + linkDamage + " dmg."); if
(ganonDamage == -1)
System.out.println("Ganon missed."); else System.out.println("Ganon did " + ganonDamage + " dmg."); } |