Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Game of (BlackJack)

deybling
deybling 


Skills Required: 1. Methods a. Passing parameters by value 2. Constructor 3. Overloading 4. Scope of variables 5. Functions Task Specifications: 1. Create an application that prompts the user for input, and will run a simulated game over and over until the user enters the word “STOP” in upper, lower, or mixed case. All user commands are shown in upper case, but any combination of upper, lower, or mixed case should work for all commands. 2. Create a function that “deals” a card by returning a random integer between 1 and 11 inclusive. 3. Create a constructor that initializes a game object. 4. Create an application that plays a game of Blackjack according to conventional rules, with the exception that there are no “Aces.” Instead, you have cards having values of 1 through 11. a. In Blackjack, the object is to accumulate cards having a sum of 21 or less. b. The player wins the game if the total of their cards is more than the total of the dealer’s cards. c. The player goes first, and may choose as many cards as they want until they either choose to stop or their total exceeds 21. d. The player can only see one of the dealer’s cards until the player has finished accepting new cards. e. The dealer wins a tie game. f. If the player “busts” then the game is over immediately, and the dealer shall not accept any new cards. 5. Display the results of the deal to the user. Update this display after each new card is dealt. 6. Request input from the user. If the user enters “HIT” then a new card will be dealt using your random function, and the results displayed. This choice will be offered until the user enters “STAY” or the user is “BUSTED” as described below. 7. If the user enters “STAY” before they are “BUSTED” then the game will resolve the dealer total, and display the results of the game. 8. If after choosing “HIT,” the value of player is more than 21, the game terminates and displays “BUSTED.” In this case, the value of the dealers numbers are resolved and displayed to the user before the game terminates. 9. When resolving the dealer’s total, the application will “HIT” the dealer for totals of 16 or less. The dealer will “STAY” on totals of 17 or more. If the value of dealer becomes greater than 21, then the application terminates and displays “DEALER BUSTED.” Otherwise, the application compares the final values of dealer and player, and reports the winner. 10. Note that it is possible to get two cards with a total of 22 on the initial deal. When this happens, regenerate the random numbers for the player or dealer so that they are not busted at the start of each game. 11. When the game terminates, the values of dealer and player should return to zero 12. The application should loop until the user enters “STOP” Evaluation Criteria 1. All tasks must be completed to receive credit for this assignment 2. Program should not crash if the user enters incorrect data Attachments Tags
Clarifications

Answers

Java - BlackJack - Solution

dickersonka
dickersonka 



Attached is the solution including source and comments to the Java - BlackJack assignment Attachments
BlackJack.java (4 K) Download Preview
displayOutput(false); //prompt user for hit or stay System.out.print("Choose HIT/STAY: "); String hOrS = input.nextLine(); if(hOrS.equalsIgnoreCase("HIT")){ playerCards.add(dealCard()); } else { hit = false; } //get player total int playerTotal = getTotal(playerCards); //check if buster if(playerTotal

Screenshots
Purchase Answer