From 00edd1e95df750a4fbcb00e96f989a9782f6763e Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 14 Feb 2024 12:47:18 -0500 Subject: [PATCH] Changed switch to Enhanced Switch. --- src/Practice/Decrease_Conquer/FakeCoin.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Practice/Decrease_Conquer/FakeCoin.java b/src/Practice/Decrease_Conquer/FakeCoin.java index 9ccbd4a..893edf5 100644 --- a/src/Practice/Decrease_Conquer/FakeCoin.java +++ b/src/Practice/Decrease_Conquer/FakeCoin.java @@ -30,7 +30,7 @@ public class FakeCoin extends Application { @Override public void executeOption(int option) { switch (option) { - case 1: + case 1 -> { System.out.println("Please enter a number of coins in the pile (including fake coin)."); System.out.print("Coin Count: "); int numOfCoins = this.getIntegerInput(); @@ -41,39 +41,38 @@ public class FakeCoin extends Application { numOfCoins = this.getIntegerInput(); } this.pile = new Coin[numOfCoins]; - break; - case 2: + } + case 2 -> { if (this.pile == null) { System.out.println("Please specify a number of coins before setting the fake location."); break; } - - System.out.println("Please specify a location for the fake coin. Between 0 and " + (this.pile.length-1)); + System.out.println("Please specify a location for the fake coin. Between 0 and " + (this.pile.length - 1)); System.out.print("Location: "); int location = this.getIntegerInput(); while (location < 0 || location >= this.pile.length) { System.out.println(); - System.out.println("Please enter a valid location: Between 0 and " + (this.pile.length-1)); + System.out.println("Please enter a valid location: Between 0 and " + (this.pile.length - 1)); System.out.print("Location: "); location = this.getIntegerInput(); } /* Implement the functionality to do both lighter and heavier. */ - this.pile[location] = new Fake(location,true); + this.pile[location] = new Fake(location, true); for (int i = 0; i < this.pile.length; i++) { if (this.pile[i] == null) { this.pile[i] = new Coin(i); } } this.setLocation = true; - break; - case 3: + } + case 3 -> { if (!this.setLocation) { System.out.println("Please specify the fake coins location."); break; } this.performAlgorithm(); - break; + } } System.out.println(); }