Blackjack game code java
BlackJack code in Java. Copyright © –, Robert Sedgewick and Kevin Wayne. Last updated: Fri Oct 20 EDT How is my BlackJack game design? Ask Question Asked 6 years, 11 months ago. Active 5 years, 10 months ago. Viewed 11k times 8. 2 \$\begingroup\$ This is a command line BlackJack game created in Java as my final project for an advanced programming class. What do you think about it? this block of code is in both main(). And as the game is so aptly titled, ye who gets closer to 21 without going over will be the victor. The gameplay logic itself is very straightforward and no more than a hundred lines of code. UI however is another story, which is why I broke the code up into elements of both. Feel free to keep the logic and update the UI to your liking.
Subscribe to RSS
There are too many magic numbers in the code. Just an additional question, my comments explaining the fisher-yates method is that correct? You need more of your functionality in separate methods to prevent you repeating yourself. Email Required, but never shown. Want to write for the SO blog?
A cleaner alternative would be to make deck , playersHand , splitHand , and dealersHand class-level variables, change the methods to be non-static, and then you won't have to pass them all around.
So something like this:. The Hand class doesn't really need a name because there are only 2 types of hands: dealer and player. So you can just pass in a boolean for drawFromDeck :. You have several different places where you're checking for blackjack, and I can't easily follow the logic.
These might be necessary I don't know the rules of Blackjack that well , but you should try to minimize duplicate logic as much as possible. For example, this block of code is in both main and hit :. I skimmed over your other classes and they seemed fine at a glance, having good separation of concerns.
Any help would be great. My code for everything is below. To compare the value of Strings,use equals :. Don't feel bad. A large proportion of questions here that this issue at their root.
Learn more. Beginners blackjack game using loops [duplicate] Ask Question. Asked 6 years ago. Active 6 years ago. Viewed 12k times. Scanner; import java. Prince Read How do I compare strings in Java?
If playAgain is a single character, use char. Polywhirl Jan 28 '14 at To compare the value of Strings,use equals : if playAgain. Want to write for the SO blog? The Overflow 9: Rust and Redux. Featured on Meta. Linked Related Hot Network Questions.
I do not like to be alone. - Анжелика смотри, а у этой бляди очень классное вымя. Cumfiesta strikes once again. 374.