public static void main(String[] args) { do { Deck deck = new Deck(); deck.shuffleDeck(1000); System.out.println("!----------Start of Hand----------!"); System.out.println(); System.out.println("Dealer"); Dealer d = new Dealer(deck.getDeck()); System.out.println(d.showCard()); System.out.println(); System.out.println("Player"); Player p = new Player(deck.getDeck()); System.out.println(p.toString()); System.out.println(); askAction(p, deck); if (!p.isBust()) { d.useDealerAI(deck); } GameRules.checkRules(d, p); System.out.println(); System.out.println("END OF HAND"); } while (askToReplay()); }
public void printPlayerNames(LinkedList<Player> players) { System.out.println("------------------------------------------------------"); for (Player player : players) { System.out.print("Player " + player.getPlayerNum() + ": " + player.getPlayerName() + " "); } System.out.println(""); System.out.println(""); }
/** * @param input String can only be H or S * @param p Player the player that is being asked * @param deck ArrayList<Card> the game deck Method is called by the askAction() method */ private static void takeAction(String input, Player p, ArrayList<Card> deck) { do { while (!input.toUpperCase().equals("H") && !input .toUpperCase() .equals( "S")) { // If the player inputs a wrong string, this dialogue will loop until the // player inputs a correct string System.out.println( "!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!"); System.out.println( " Oops! You entered in a wrong letter. HINT: enter H for hit and S for stay"); System.out.println( "!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!"); Scanner scan = new Scanner(System.in); System.out.print("Do you want to hit or stay? H/S: "); input = scan.nextLine(); } if (input .toUpperCase() .equals("H")) { // If the player wants to hit, the hit() Player object method is called p.hit(deck); } if (input .toUpperCase() .equals("S")) { // If the player wants to stay, the stay() Player object method is called p.stay(); } if (p.isBust()) { input = "S"; } else if (!input.equalsIgnoreCase("S")) { Scanner scan = new Scanner(System.in); System.out.print("Do you want to hit or stay? H/S: "); input = scan.nextLine(); } } while (input.equalsIgnoreCase("H") && !input.equalsIgnoreCase("S")); }