outprintlnYour Hand playertoString value is

Outprintlnyour hand playertostring value is

This preview shows page 1 - 3 out of 3 pages.

System.out.println("Your Hand: " + player.toString()); System.out.println("Your value is: " + player.cardsValue()); //Dealer's Hand and value System.out.println("\n Dealer Hand: " + dealer.getCard(0).toString() + " and a [Hidden] card");
Image of page 1
if (player.cardsValue() == 21) { System.out.println("21!!! You Win"); money = money + bet; roundEnd = true; break; } //Ask play to hit or stay System.out.println("Would you like to (1)Hit or (2)Stand"); int response = input_2.nextInt(); //They hit if (response == 1) { player.deal(playingDeck); System.out.println("You draw a:" + player.getCard(player.deckSize() - 1).toString()); //Bust if they go over 21 if (player.cardsValue() > 21) { System.out.println("BUSTED! Your valued is: " + player.cardsValue()); money -= bet; roundEnd = true; break; } } //Stand if (response == 2) { break; } } //Reveal Dealer Cards System.out.println("Dealer Cards:" + dealer.toString()); //See if dealer has more points than player if ((dealer.cardsValue() > player.cardsValue()) && roundEnd == false) { System.out.println("Dealer beats you " + dealer.cardsValue() + " to " + player.cardsValue()); money -= bet; roundEnd = true; } //Dealer hits at 16 stands at 17 while ((dealer.cardsValue() < 17) && roundEnd == false) { dealer.deal(playingDeck); System.out.println("Dealer draws: " + dealer.getCard(dealer.deckSize() - 1).toString()); } //Display value of dealer System.out.println("Dealer value is : " + dealer.cardsValue()); //Determine if dealer busted if ((dealer.cardsValue() > 21) && roundEnd == false) { System.out.println("Dealer Busts. You win!"); money += bet; roundEnd = true; } //Determine if push if ((dealer.cardsValue() == player.cardsValue()) && roundEnd == false) { System.out.println("Push."); roundEnd = true; }
Image of page 2
//Determine if player wins if ((player.cardsValue() > dealer.cardsValue()) && roundEnd == false) { System.out.println("You win the hand."); money += bet; roundEnd = true; } else if (roundEnd == false) //dealer wins { System.out.println("Dealer wins."); money -= bet; } //End of hand - put cards back in deck player.moveAllToDeck(playingDeck); dealer.moveAllToDeck(playingDeck); System.out.println("End of Hand."); } //Game is over System.out.println("Game over! You lost all your money. GOOD BYE! "); } }
Image of page 3

You've reached the end of your free preview.

Want to read all 3 pages?

  • Fall '16
  • JOSEPH DEMASCO
  • Store of value, System.out.println, player, Mini Project 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture