Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: BlackJack Help

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default BlackJack Help

    A player is dealt an initial hand of two cards. He has the option of drawing cards to bring the total
    value to 21 or less without exceeding it, so that the dealer will lose by having a lesser hand than
    the player or by exceeding 21. The dealer also receives an initial hand of two cards.

    However,
    only the first card is visible to all. The other card is not visible until the dealer's turn. The dealer
    starts his turn after every player stood (decided to take no more cards) or busted (value above
    21). A player hits when he decides to take another card from the dealer. A player busts when his
    hand value is above 21. When a player is busted, his chips is immediately forfeited regardless
    whether the dealer is busted or not. When a dealer is busted, the remaining players who are not
    busted wins. When there is a tie between the dealer and the player, the chips is returned to its
    player.


    Develop a Java program for the Blackjack card game. Do not implement additional options such as
    "double", "split" or "surrender".
    Required Functionality
     User registration of up to three players (A to C).
     Player's name must be at least three characters.
     Each player is to be given 100 chips at the beginning of the game.
     Dealer has unlimited amount of chips.
     Players cannot place chips of more than what they have.
     Each player or dealer has a hand of maximum five cards.
     Enforce turn-based dealing of cards to players.
     Display the value of a player's hand after a card is dealt.
     Allow players to stand or to hit.
     A player leaves the game when he has no more chips.
     The game ends when all players lose all their chips.

    Coding Restrictions
     You must use simple (1-D) arrays in this assignment.
     You are not allowed to use 2-D arrays, ArrayList and LinkedList as your data structures.
     You are not allowed to implement any form of GUI (E.g. Swing, AWT, etc.)


    Sample Output
    Players Registration
    B L A C K J A C K
    ================================================== ==============================
    Enter number of players (1-3) > 3
    Enter Name of Player A > Ben
    Enter Name of Player B > Joy
    Enter Name of Player C > Frank
    B L A C K J A C K
    ================================================== ==============================
    Enter number of players (1-3) > 2
    Enter Name of Player A > He
    *** NAME TOO SHORT!
    Enter Name of Player A > Bee
    Enter Name of Player B > Jude

    Displaying the Game
    ================================================== ==============================
    Player A, You have 100
    Enter number of chips to play > 100
    Player B, You have 100
    Enter number of chips to play > 100
    Player C, You have 100
    Enter number of chips to play > 80
    --------------------------------------------------------------------------------
    DEALER
    <Heart Ace>
    --------------------------------------------------------------------------------
    Player A
    <Club Five>
    <Club Ace>
    [H]it or [S]tand S
    PLAYER A : Joe
    Value : 16
    Hand : <Club Five> <Club Ace>
    --------------------------------------------------------------------------------
    Player B
    <Heart Two>
    <Diamond Nine>
    [H]it or [S]tand H
    <Spade Two>
    [H]it or [S]tand H
    <Diamond Four>
    [H]it or [S]tand H
    <Diamond Ace>
    [H]it or [S]tand S
    PLAYER B : Ben
    Value : 18
    Hand : <Heart Two> <Diamond Nine> <Spade Two> <Diamond Four> <Diamond Ace>
    --------------------------------------------------------------------------------
    Player C
    <Spade Jack>
    <Diamond Jack>
    [H]it or [S]tand S
    PLAYER C : Tay
    Value : 20
    Hand : <Spade Jack> <Diamond Jack>

    DEALER
    Value : 21
    Hand : <Heart Ace> <Spade Queen>
    DEALER
    Value : 21
    Hand : <Heart Ace> <Spade Queen>
    ================================================== ==============================
    Player A. Lost 100
    Player B. Lost 100
    Player C. Lost 80
    ================================================== ==============================
    Player C, You have 20
    Enter number of chips to play > 20
    --------------------------------------------------------------------------------
    DEALER
    <Heart Four>
    --------------------------------------------------------------------------------
    Player C
    <Spade Ten>
    <Heart Six>
    [H]it or [S]tand H
    <Spade Six>
    PLAYER C : Tay
    Value : 22
    Hand : <Spade Ten> <Heart Six> <Spade Six>
    --------------------------------------------------------------------------------
    DEALER
    Value : 14
    Hand : <Heart Four> <Club Ten>
    [H]it or [S]tand S
    DEALER
    Value : 14
    Hand : <Heart Four> <Club Ten>

    Player C. Busted. Lost 20
    G A M E O V E R

    Various Messages Displayed During Game Play
    ================================================== ==============================
    Player A. Won 80.
    Player B. Tied with Dealer.
    Player C. Busted. Lost 100.
    Player A, You have 100
    Enter number of chips to play > 120
    *** YOU CANNOT PLAY MORE THAN WHAT YOU HAVE.
    Player A, enter amount of chips to play >

    ################################################## #############################

    I need to create 4 classes consists of BlackJackGame, Deck, Player and Card class

    BlackJackGame consists of

    dealer : Player
    players : Player[]
    deck : Deck
    numPlayer : int

    main(String []) : void
    start() : void
    registerPlayers() : void
    ask PlayersPlaceChips() : void
    dealCardsToDealer() : void
    dealCardsToDealer2() : void
    dealCardsToPlayers() : void
    determineWinLoseOrTie() : void
    isGameOver() : boolean

    Deck class consists of

    deck : Card[52]
    cardsDispensed : int

    Deck()
    dispenseCard() : Card
    createDeck() : void
    shuffleDeck() : void

    Card class consists of

    suit : int
    number : int

    Card(int, int)
    getScore() : int
    getTitle() : String
    display() : void

    Player class consists of

    id : char
    name : String
    chips : int
    stake : int
    hand : Card[5]

    Player(Char, String)
    leftGame() : boolean
    placeStake(int) : void
    win() : void
    lose() : void
    hit(Card) : void
    valueOfHand() : int
    clearHand() : void
    displayStatus() : void
    Last edited by programming_nerd; November 19th, 2011 at 08:02 AM.


  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: BlackJack Help

    This is what I have done so far

    My Card Class
    public class Card {
    public int suit; 
    public int number; 
     
    private final String[] Digit = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
    private final String[] Symbol = {"Spade", "Heart", "Diamond", "Club"};
     
    public Card(int suit, int number){
    this.suit = suit;
    this.number = number; 
    }
    public int getScore(){
    return number;
    }
    public int getTitle(){
    return suit;
    }
    public void display(){
    String value = Digit[number];
    String shape = Symbol[suit];
    System.out.println(shape + " " + value);
     
     
    }
    }

    My Deck Class

    public class Deck {
    public Deck[] Card = new Deck[52];
    public int cardsDispensed;
     
    public Deck(){
     
    }
    public Card dispenseCard() {
     
    }
     
    public void createDeck(){
     
    }
     
    public void shuffleDeck(){
     
    }
    }
    There is a red line beneath the dispenseCard() . I do not know what is wrong with it.

    I have not work on my BlackJack and Player class. Anyone knows how to help?? Thanks alot man
    Last edited by JavaPF; November 19th, 2011 at 08:48 AM. Reason: Use highlight tags!

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: BlackJack Help

    There is a red line
    Can you compile the program and get some error messages from the compiler? If so, copy and paste them here if you do not understand them and need help.
    Otherwise read the doc for your IDE to see how you can have it tell you why it is drawing a red line.

  4. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: BlackJack Help

    I don't understand anything. I need someone to do my homework.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: BlackJack Help

    I need someone to do my homework.
    Have you asked your mother?

  6. #6
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: BlackJack Help

    Quote Originally Posted by Norm View Post
    Have you asked your mother?
    Sorry; this was definitely worth a lol.
    Last edited by Tjstretch; November 22nd, 2011 at 03:25 AM.

Similar Threads

  1. BlackJack Java
    By programming_nerd in forum Member Introductions
    Replies: 0
    Last Post: November 19th, 2011, 07:14 AM
  2. Freezing on bust (BlackJack)
    By DaffyPWNS in forum What's Wrong With My Code?
    Replies: 9
    Last Post: June 16th, 2011, 09:40 PM
  3. Blackjack simulation program help
    By senorfletch in forum Java Theory & Questions
    Replies: 2
    Last Post: April 5th, 2011, 09:22 AM
  4. Help with blackjack game
    By santosd1118 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 12th, 2010, 12:55 AM
  5. A little help with my Blackjack code
    By Neophyte in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 3rd, 2010, 01:13 PM