Question: please, help this error.... /BlackJack.java:156: error: exception IOException is never thrown in body of corresponding try statement } catch (IOException ex) { ^ ./BlackJack.java:174: error:
please, help this error....
/BlackJack.java:156: error: exception IOException is never thrown in body of corresponding try statement } catch (IOException ex) { ^ ./BlackJack.java:174: error: exception IOException is never thrown in body of corresponding try statement } catch (IOException ex) {
========================================================================================
package blackjack;
import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Scanner; import java.io.IOException;
public class BlackJack { private static BlackJack current;
public static BlackJack getInstance() { if (current == null) { current = new BlackJack(); }
return current; }
public static void freeInstance() { current = null; }
private BlackJack() { super(); }
private Random random = new Random(); private Scanner scan = new Scanner(System.in); private ArrayList
public void playGame() { ... } private void makeDeck() {...} private int selectInput() { int selectNum; while (true) { try { selectNum = Integer.parseInt(scan.nextLine()); break; } catch (NumberFormatException ex) { System.out.println("Number fromat error: = " + ex.getMessage()); System.out.println("You must enter a number. Please re-enter the number"); continue; } catch (IOException ex) { System.out.println("Unknown input. Please enter the correct number."); continue; } } return selectNum; }
private int batting() { while (true) { System.out.println("How much would you like to bet? The minimum betting amount is $1)."); try { money = Integer.parseInt(scan.nextLine()); } catch (NumberFormatException ex) { System.out.println("Nomber format error: = " + ex.getMessage()); System.out.println("You must enter a number. Please re-enter the number"); continue; } catch (IOException ex) { System.out.println("Unknown input. Please enter the correct number."); continue; } if (0 < money && money < 1) { System.out.println("Please, enter a minimum amount of betting"); continue; } else if (money == 0) { System.out.println("You have to bet to participate."); continue; } else if (money < 0) { System.out.println("Stop being silly and enter a real command"); continue; } else break; } return money; } private void drawTwoCard() {...} private void hit() {...} private void stay() {....} private void stayResult(PrintString printResult) {....}
===============================================
package blackjack;
public class Play { public static void main(String[] args) { BlackJack.getInstance().playGame(); } }
================================================
package blackjack;
import java.util.List;
public class PrintString {...}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
