From a78c1e812209d2a5f6f20afb0207725a4aba0442 Mon Sep 17 00:00:00 2001 From: Tim Buchalka <70119791+journich@users.noreply.github.com> Date: Sun, 9 Jan 2022 06:50:24 +1030 Subject: [PATCH] Another issue #457 bugfix. Player selecting enemy weapons option BOTH (GUNS and MISSILES) now calculates amount correctly resulting in a higher likelyhood of being shot down. Added comments to make it clearer how the calculation worked for all enemy weapons. --- 12_Bombs_Away/java/src/BombsAway.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/12_Bombs_Away/java/src/BombsAway.java b/12_Bombs_Away/java/src/BombsAway.java index b084ddcb..290b2c6d 100644 --- a/12_Bombs_Away/java/src/BombsAway.java +++ b/12_Bombs_Away/java/src/BombsAway.java @@ -281,18 +281,20 @@ public class BombsAway { if(enemyDefences == null) { System.out.println("TRY AGAIN..."); } else { + chanceToBeHit = 35; switch(enemyDefences) { case MISSILES: - chanceToBeHit = 35; + // MISSILES... An extra 35 but cannot specify percentage hit rate for gunners break; case GUNS: - - // fall through (no break) on purpose to case BOTH - // since it's identical code for GUNS or BOTH weapons + // GUNS... No extra 35 but can specify percentage hit rate for gunners + chanceToBeHit = 0; + // fall through (no break) on purpose because remaining code is applicable + // for both GUNS and BOTH options. case BOTH: - chanceToBeHit = 0; + // BOTH... An extra 35 and percentage hit rate for gunners can be specified. percentageHitRateOfGunners = getNumberFromKeyboard("WHAT'S THE PERCENT HIT RATE OF ENEMY GUNNERS (10 TO 50)? "); if(percentageHitRateOfGunners < 10) { System.out.println("YOU LIE, BUT YOU'LL PAY...");