Make a blackjack game, play against the computer-dealer.
Nhu Nguyen 10abd4d07b added blackjack 6 jaren geleden
.idea added blackjack 6 jaren geleden
src/rocks/zipcode added blackjack 6 jaren geleden
test/rocks/zipcode added blackjack 6 jaren geleden
.gitignore bluej 6 jaren geleden
README.TXT bluej 6 jaren geleden
README.md Update 'README.md' 6 jaren geleden
package.bluej bluej 6 jaren geleden
pom.xml just before break 6 jaren geleden

README.md

ZCW-Lab-Blackjack-BlueJ

Make a blackjack game, play against the computer-dealer. Aces are always, only, 1.

Writing a Blackjack program

Create a BlackJack class, with a runGame() method.

  1. Define your methods:
    • hit() or deal_card()
    • dealerDraw(dealerScore)
    • checkWin(dealerScore,playerScore)
    • isBust(score)
  2. Make a variable called endGame and set it equal to False
  3. Make a loop that only runs while endGame is False (i.e. the game has not ended)
  4. Inside the loop, get input from the player to ask what he wants to do
    • If his input was “stick”
    • print out his total and the dealer’s total
    • check who has won and print it
    • end the game
    • If his input was “hit”:
    • draw him a new card and add it to his total
    • check if he has bust – if so the game ends and he loses, if not print his new total
    • if he didn’t bust, decide whether the dealer will draw
    • check if the dealer is bust – if so the game ends and the player wins

That’s all!

you might want to use...

public int generateRandomInt() {
    int min = 1;
    int max = 10;
    Random r = new Random();
    return r.nextInt((max - min) + 1) + min;
    }

You will have to put import java.util.Random; at the very top of your class file.