Java Blackjack

java
February 4, 2012 – 09:53 am
Java code blackjack game

Lookup tables.

Here's one I randomly found on the internet:

from width=

All you gotta do is make a 2D array, populate it with the right values (enum?), and alter your play(Card upCard) method to use the lookup table.

That solves your complexity issue, your implicit data storage (you're trying to algorithmically map the values of 3 variables (card 1, card 2, dealer up card) to a lot of different values), and it should be a speedup too. Plus, what are blackjack explanations doing in your code?

Note that you might have to split your lookup table in three sections: One for the doubles, one for the case where you have an ace, and one for the last case, where you need to use the total of your hand.

That said, looking at your code, there's some things that could also look a bit differently:

getHand.get(0).getName.equals("Ace") | getHand.get(1).getName.equals("Ace")

Seems like this could get wrapped into a method called containsCard(String name). I'm worried about a single pipe though - Isn't it ||?

getHand.get(0).getName.equals("Ace") & getHand.get(1).getName.equals("Ace")

Same thing here: this could be boolean hasPair. Also, isn't it &&?

getHand.get(0).getName.equals("Two") | getHand.get(1).getName.equals("Two") & upCard.getValue >= 5 & upCard.getValue

Source: codereview.stackexchange.com
Resources
  • jogo 9 masks of fire
  • https://www.babu-88.bet/


Interesting facts

Extreme Snap is an more complex version of the popular children's card game Snap. Extreme snap is very quick to play, with rounds typically lasting less than 5 minutes, although then can occasionally last much longer, especially when players are of roughly equal ability. Technically the minumum number of players is 2, but 4 players is the...

You might also like
Blackjack - Java
Blackjack - Java
My first Java project: Console BlackJack
My first Java project: Console BlackJack
Wellcoda | Ace Heart Hustler USA Womens NEW Casino Fun Black Hoodie 2XL
Apparel
  • Your Orders Shipped Within 24 Hours with 60 Day Return to US
  • Premium Quality, Professionally Hand Printed Apparel from the UK
  • Extremely Comfortable, 100% Ethically Sourced Cotton. Machine Washable
  • Wellcoda Promise®: For every tree used in our Apparel, 10 Tree s are planted
  • Wellcoda Planet®: 52% of the energy used to make this garment came from Renewable Energy
Paradise Cash Treasure Slots Sunproof Hustler Flood
Mobile Application (Paradise Cash Treasure)
  • Start winning huge for free and play this free slots game for big jackpot clash! Play slots offline free and get those juicy jackpot wins coming in bonanza style...
  • Play an amazing slots game free with fast interface, sweet graphics and gorgeous sounds with complete offline slots free play. Compatible with Amazon Kindle Fire...
  • Discover new slots lucky daily bonus rounds with multiple round saga blitz. Claim bonuses every day and rush 2 xtreme slots Vegas casino speed to win and achieve...
  • Test your luck like in the wheel of fortune and bash those daily slots rounds,in bigg epic challenges when you play in slots pleasure craze and joy. You dont need...
  • Change your way to play slots with the best bonus slots games offered here while you transformers mini games and build up your powerups rounds for free. Surrender...
  • Jump in to the real game of slots and play large USA design styles and rooms with jackpot party wins and multi-millions rounds and slots rounds to play. Boost your...
  • Download our free slots games and enjoy different themes inspired by Las Vegas designs with the classic slots themes. Boost slots luck with fish paradise jackpots...
  • Simple and easy slotsgame has special bonus free slots rounds to play. Other casinogames game lovers who like live poker, slots, blackjack, dominoes, keno and solitaire...
  • Play slots offline or online for free and dont worry about internet connection because there is no wifi needed to play the bestslots!
Popular Q&A
avatar
Help with JAVA blackjack game? | Yahoo Answers

Assuming game play is set up in a method, just return from the method... You can then handle what happens next however you'd like, including reentering the method to play another "hand".

Related Posts