Blackjack.pdf - import java.util.Scanner/allows input...

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

import java.util.Scanner ; //allows input public class Blackjack { public static void menu(){ //method that contains the menu System.out.println( "1. Get another card" ) ; System.out.println( "2. Hold hand" ) ; System.out.println( "3. Print statistics" ) ; System.out.println( "4. Exit" + " \n " ) ; System.out.print( "Choose an option: " ) ; } public static void main(String[] args){ Scanner input = new Scanner(System.in) ; int gameNum = 0 ; // number of the game currently playing int option ; // selection from menu boolean game = true; int wins = 0 ; int loses = 0 ; int ties = 0 ; P1Random rng = new P1Random() ; // allows a random number to be generated while (game) { //start of game gameNum++ ; System.out.println( "START GAME # " + gameNum + " \n\n " ) ; boolean contGame = true; boolean firstDeal = true; boolean finish= true; boolean nextStep = true; int dealerHand ; int playHand = 0 ; while (contGame) { // continuation of the game if (firstDeal){ int cardNum = rng.nextInt( 13 ) + 1 ; //draws a random card if (cardNum == 1 ) { playHand += 1 ; // value of an ace System.out.println( "Your card is a ACE!" ) ; } else if (cardNum >= 11 ) { playHand += 10 ; // value of face cards while ( true )

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture