Black Jack.docx - CS 140 Java PROGRAMMING Fall 2019 Lab Report[04 \u2013 Black Jack ID A00250811 Name Steven Perumean Date BLACK JACK CODE Package

Black Jack.docx - CS 140 Java PROGRAMMING Fall 2019 Lab...

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

CS 140 Java PROGRAMMING Fall 2019 Lab Report [04] – Black Jack ID: A00250811 Name Steven Perumean Date 10/06/19 BLACK JACK CODE: Package blackjackyes; import java.util.Scanner; public class blackjack { public static void main(String[] args) { //Welcome Message System. out .println("Welcome to Blackjack!"); //create out playing deck Deck playingDeck = new Deck(); playingDeck.createFullDeck(); playingDeck.shuffle(); //Create a deck for the player Deck playerDeck = new Deck(); Deck dealerDeck = new Deck(); double playerMoney = 100.00; Scanner userInput = new Scanner(System. in ); //Game Loop while(playerMoney > 0) { //Keep Playing! //Take Players bet System. out .println("You have $" + playerMoney + ", how much would you like to bet?"); double playerBet = userInput.nextDouble(); if(playerBet > playerMoney) { System. out .println("You cannot bet more than you have. Please get the heck out of my Casino."); break; } boolean endRound = false; //Start Dealing //Player gets 2 cards playerDeck.draw(playingDeck); playerDeck.draw(playingDeck); //dealer gets 2 cards dealerDeck.draw(playingDeck); dealerDeck.draw(playingDeck); Instructor : Keng S. Chang [email protected]
Image of page 1
CS 140 Java PROGRAMMING Fall 2019 while(true) { System. out .println("Your hand: "); System. out .print(playerDeck.toString()); System. out .println("Your deck is valued at: " + playerDeck.cardsValue()); //Display Dealer HHand System. out .println("Dealer Hand: " + dealerDeck.getCard(0).toString() + " and [Hidden]" ); //What does player want to do? System. out .println("Would you like to (1) Hit or (2) Stand?"); int response = userInput.nextInt(); if(response == 1) { playerDeck.draw(playingDeck); System. out .println("You draw a: " + playerDeck.getCard(playerDeck.deckSize()-1).toString()); //Bust if > 21 if (playerDeck.cardsValue() > 21){ System. out .println("Bust. Currently valued at: " + playerDeck.cardsValue());
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 6 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture