Changed switch to Enhanced Switch.

This commit is contained in:
Jonathan Turner 2024-02-14 12:47:18 -05:00
parent 5f37a3a97b
commit 00edd1e95d

View File

@ -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,13 +41,12 @@ 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.print("Location: ");
int location = this.getIntegerInput();
@ -66,14 +65,14 @@ public class FakeCoin extends Application {
}
}
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();
}