Changed switch to Enhanced Switch.
This commit is contained in:
parent
5f37a3a97b
commit
00edd1e95d
@ -30,7 +30,7 @@ public class FakeCoin extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void executeOption(int option) {
|
public void executeOption(int option) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 1:
|
case 1 -> {
|
||||||
System.out.println("Please enter a number of coins in the pile (including fake coin).");
|
System.out.println("Please enter a number of coins in the pile (including fake coin).");
|
||||||
System.out.print("Coin Count: ");
|
System.out.print("Coin Count: ");
|
||||||
int numOfCoins = this.getIntegerInput();
|
int numOfCoins = this.getIntegerInput();
|
||||||
@ -41,39 +41,38 @@ public class FakeCoin extends Application {
|
|||||||
numOfCoins = this.getIntegerInput();
|
numOfCoins = this.getIntegerInput();
|
||||||
}
|
}
|
||||||
this.pile = new Coin[numOfCoins];
|
this.pile = new Coin[numOfCoins];
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
if (this.pile == null) {
|
if (this.pile == null) {
|
||||||
System.out.println("Please specify a number of coins before setting the fake location.");
|
System.out.println("Please specify a number of coins before setting the fake location.");
|
||||||
break;
|
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: ");
|
System.out.print("Location: ");
|
||||||
int location = this.getIntegerInput();
|
int location = this.getIntegerInput();
|
||||||
while (location < 0 || location >= this.pile.length) {
|
while (location < 0 || location >= this.pile.length) {
|
||||||
System.out.println();
|
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: ");
|
System.out.print("Location: ");
|
||||||
location = this.getIntegerInput();
|
location = this.getIntegerInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implement the functionality to do both lighter and heavier. */
|
/* 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++) {
|
for (int i = 0; i < this.pile.length; i++) {
|
||||||
if (this.pile[i] == null) {
|
if (this.pile[i] == null) {
|
||||||
this.pile[i] = new Coin(i);
|
this.pile[i] = new Coin(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setLocation = true;
|
this.setLocation = true;
|
||||||
break;
|
}
|
||||||
case 3:
|
case 3 -> {
|
||||||
if (!this.setLocation) {
|
if (!this.setLocation) {
|
||||||
System.out.println("Please specify the fake coins location.");
|
System.out.println("Please specify the fake coins location.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.performAlgorithm();
|
this.performAlgorithm();
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user