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 game

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Blackjack game

    I'm writing a blackjack game just to try and brush some rust off. I'm not looking for any code, but more the theory/steps behind how to write a deal class.

    I've got a functional deck generator, and I can shuffle my deck with no problem. Now I've turned my attention to dealing from this shuffled deck. At some point I will probably go back and re-write the fischer-yates shuffle algorithm instead of using Collections.shuffle(). Don't want to tackle that just now though. At some point I may try to add in bets/doubledowns/splits as well.

    anyway... deal method in Deal class, my foggy thoughts so far.

    scenario 1.
    Deal two cards
    Pass them into a dealer arraylist,
    Deal two more cards
    Pass them into a player arraylist.

    send the various arraylists to player-specific methods.

    Scenario 2.

    Deal four cards
    Split the cards in two.
    send the cards to different methods for each player.

    scenario 3.
    instantiate Deal twice. (once for player, once for Dealer)
    pass cards to various methods.


    Am I overlooking something? I'm not worried about hitting or staying at this point. Just a successful deal.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Blackjack game

    Either one seems reasonable. There are also other way to approach the problem, but you should go with whatever fits into your head the best. I'm not sure what else you're looking for from us?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Blackjack game

    Quote Originally Posted by KevinWorkman View Post
    Either one seems reasonable. There are also other way to approach the problem, but you should go with whatever fits into your head the best. I'm not sure what else you're looking for from us?
    That's pretty much all. Those are just the ways to accomplish a deal that pop into my head. I wouldn't mind some other general problem approaches. If not that's alright too. This is a purely personal project to shake some rust off.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Blackjack game

    Quote Originally Posted by roscowgo View Post
    That's pretty much all. Those are just the ways to accomplish a deal that pop into my head. I wouldn't mind some other general problem approaches. If not that's alright too. This is a purely personal project to shake some rust off.
    Fair enough. But if you want my $.02, go with your gut. Five people could give you ten different ideas, but you're the one who has to implement it. If it fits in your head, go for it, and don't spend too much time worrying about whether it's the absolute best way to go about designing your program. Chances are, in six months you'll look back at your code and cringe no matter what you chose to do. That's not an insult, it's just a part of learning how to program again.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Blackjack game

    I absolutely agree about looking back and cringing, understand exactly what you're saying there. The hardest part of programming for me so far has been learning how to think my way through the logic. Where do I want to send this, what do I want back... why do I want it back etc. So knowing that I try to force my head around and through the solutions I come up with when I'm practicing. Remembering the syntax and fitting it together with the correct data types/formatting comes in a distant second.

    I re-wrote my card generator at least three complete times for instance.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Blackjack game

    I guess the knack of knowing how to organize your project comes with experience, but that's probably just as much simply coming up with your own flow that makes sense in your head and accepting that nothing you come up with will be perfect as it is familiarizing yourself with design patterns. Even so, you'll still come across instances where you end up rewriting large portions of your project, even after you've been developing for years.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. BlackJack Help
    By programming_nerd in forum Object Oriented Programming
    Replies: 5
    Last Post: November 22nd, 2011, 03:21 AM
  2. BlackJack Java
    By programming_nerd in forum Member Introductions
    Replies: 0
    Last Post: November 19th, 2011, 07:14 AM
  3. How to add card images to Blackjack game??
    By Jayc44 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 15th, 2011, 12:43 PM
  4. BlackJack Game can"t figure out how to finsh it.
    By flurr in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 13th, 2011, 10:06 AM
  5. Help with blackjack game
    By santosd1118 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 12th, 2010, 12:55 AM