You are to create a program whereby a single user can play a variation of blackjack against a virtual dealer robot.
Blackjack is a popular card game. At the end of the game, the player with highest value cards wins, but those cards cannot be worth more than 21 points, or the player loses.
Play progresses as follows:
- Two cards are given and displayed to the user.
- Two cards are given to the dealer, but these are secret and not displayed to the user.
- The user is prompted whether they would like an additional card. They can request as many additional cards as they would like, until they choose to "stop", "stand", or "pass". If the value of the cards exceeds 21 at any point during this process, the user has "busted" and lost, and the game ends.
- The robotic dealer decides whether to request as many additional cards as it wants. You can have the robot dealer do this at random if you like, or you can develop an artificial intelligence algorithm. If the robot dealer's cards exceed 21 points during this process, the dealer has busted and lost, and the user wins.
- At the end of the game, if the user's cards are higher in total value than the dealer's cards, the user wins. Otherwise, the dealer wins.
- Regardless of how the game ends, the program must show the user what cards the dealer has at the end of the game.
- Do not worry about drawing the same card twice. Draw cards at random.
- All "cards" are simply integer values from 2 thru 11.
- These rules are slightly different from how blackjack is played in casinos.
The following is a rough flow chart showing the flow of this program.
Create the program using Swing GUI components, including images of the cards that are dealt.
Hint: you may want to look up how to create image icons in your book's index. They can be used in JOptionPane dialogs.