Free Blackjack

Checking that should be under your whoWon method, and printing it should be controlled by another method. Caribbean Stud Poker Online. You have Card s. I think it's reasonable to ignore this effect for a simple simulated game, but if you wanted a next step you might look up shuffling algorithms: The blackjack sites listed below are the top places to play for real money online. Get the Best Bonus Here.

Free Online Blackjack Variations

What Makes our Free Blackjack Game Different?

I have many, many, many more words for those that make games to learn. I like such exercises. However, I think that this is enough for today. I hope you get more answers and use these in your learning project to post a follow-up question. Questions like these are fun to answer.

I would make the dealer in location 0 of the players array, as this means that you can pass around your array of players, and rely on the fact that no matter how large the array is, player[0] is the dealer.

As well as this, you're duplicating data by both creating a Player user and a Dealer dealer as well as storing that in the array.

I'd just store it in the array. As a slight aside, I'd make it an ArrayList, but if you're trying to just use simple data types, I understand why not, but it's something to consider if you're planning to allow more than 1 player in the future. As well as this, moving all of your initialization logic to a single method might be a good idea. This can include your welcome text. I know that you said that you are aware of the recursive call to main being a bad thing, but I thought I should suggest an alternative anyway.

The game loop pattern , where you have a initialize then just a update , can apply here, in a simple form. You can make Update be in a while notQuit loop, which can contain all of your logic. PlayerTurn has quite a few responsibilites, which is something that you don't really want out of a function.

I'd pass it just one player, the one who's turn that it is, and return without printing out anything other than what it needs to the score after the player has taken a card , as it shouldn't have any responsibility over reporting who won. Checking that should be under your whoWon method, and printing it should be controlled by another method. In goAgain , you're checking the boolean against null.

This is how I'd write that method:. It's functional, it works, and if you're going for simple, this is it. However, it's not very flexible, and it doesn't involve the notion of a deck, so it's possible to get 5 2s in a row. Whether you want to do that is up to you, but there's plenty of card implementations on this site that'll give you pointers.

I'd possibly have a getName. I know that you've overridden toString , but that's not the first thing that I'd look for if I were using this interface. I'd definitely make Hand an ArrayList. They get more then 2 cards in blackjack, and the cards can have different values depending on how the hand is Ace can be high or low. The rest of my issues with this class is summarised with make hand an arrayList. Resizing arrays is expensive and adding 1 element to a list is less so.

Something nobody else seems to have mentioned yet: It's true that there are nine possible card values in a game of blackjack, but they're not all equally likely. In a real deck of cards, there are thirteen ranks, four of which are worth ten points in blackjack. This will make the game a lot less fun. The way I would handle this is to actually simulate all thirteen possible ranks with the numbers 2—13 in your random loop. Your Card class would then have a blackjackValue method that you can use for scoring purposes.

Another option would be to build an array with all the possible scores and select a random element. You'd put the value ten in this array four times, and the nine values all go in there once.

This is slightly slower and more complex, but it gets you closer to a real shuffling algorithm. If you're confident your Card will never be used for anything but Blackjack, you could just call your method points , but in my experience you should never assume your classes won't be reused for something you didn't foresee.

Of course there's a deeper issue with your scheme, which is that in a real game the deck has a "memory" of which cards have already been played. This is the effect that allows card counters to gain a statistical advantage in Blackjack. I think it's reasonable to ignore this effect for a simple simulated game, but if you wanted a next step you might look up shuffling algorithms: Real Vegas casinos typically use something like six decks and reshuffle when they're roughly halfway through.

That's enough cards that your random-card approach is going to be pretty close to real most of the time. Going with the other answers, you need to create a cards class member of decks or similar to put the card information in. You need to make sure you have at least 52 unique cards Ace through to King, one of each suit to create a deck. The reason for this is being able to reuse the code, and for Blackjack's rules about Aces: Currently, they could be dealt two "11"'s, and they would instantly bust.

If they are dealt an Ace and a Nine, and they hit and get a Ten, they need to treat the first Ace as just a 1, not as an By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service , privacy policy and cookie policy , and that your continued use of the website is subject to these policies. Home Questions Tags Users Unanswered. Text-based BlackJack game Ask Question.

I am a new programmer I've been doing Java for about 7 weeks and I am of the type who wants to get it right straight away, so I wonder how this code: Compares to the common practice is structured. Is it a good structure? Is it easy to read? The JavaDoc; what could I improve? I am not including the package or imports for space reasons This code has a recursive call back to main. And user goes always first. It returns the winner. She will hit until her hand is It will then draw and display the initial hand of two cards.

Pimgd 21k 5 56 Gemtastic 1 8 Recursive Main and Design You can easily remove the recursive call to main by having main consist of the following: Does BlackJackGame represent a single hand or a set of hands? Why does BlackJackGame need to be prompted to ask for a new game Future Features You have Card s.

Blackjack in casino's has betting, of course. That's the point of playing blackjack. Other features I can think of: Print the message "Dealer stands on X" - for blackjack, dealer rules are usually fixed.

Allow the game to print some help Have other players play next to you, each with some silly strategy and voila, you have something to score your betting mechanic against Aces have a value of either 1 or Right now, one can draw two aces and immediately be bust. When the dealer has blackjack, the dealer immediately reveals their hand. Player can't do anything about it and just loses.

Library Usage No, not books. Code shortcuts Here's some shortcuts you can use that are well-known: I'd rewrite the function like this: So this becomes if game.

This has three benefits: If the statement player. Your game now has Decks, Splits, betting, multiple players, logging, statistics, save and load, ASCII card images and basically so much features that your text-based game is now 10K lines.

At least, that's where my text-based game ended up when I started to learn programming. How will you increase a minimum bet from 1 to 5? You can't just search your code for "1". Play whatever game you want instantly, whenever you want. Simply log in to your player account and place your bets right from your Web browser. Unfortunately in this Microsoft-driven world, many online casinos do not offer downloadable games that are compatible with operating systems other than Windows.

This is where no download casino game applets come in particularly handy. With a Flash or Java blackjack interface, for example, you never need to download anything other than those regular browser updates that install immediately. No tedious restarts on your computer are necessary here. No matter what operating system you prefer to use, you can play Flash or Java blackjack in whatever browser you have on your computer, tablet, or mobile phone. Online gambling sites that provide no download options for access to their games open up the world of online gambling to everyone with an Internet connection, regardless of operating system, so you do not have to get bogged down with issues of software compatibility.

No one software approach is perfect, and Java and Flash blackjack casino games are no exception to this truth. If you are looking for high resolution graphics or a wide array of in-game options, you should probably look elsewhere.

The software platforms of no-download browser games are smaller and use less system resources, so they allocate less emphasis to graphics, game options, and other cosmetic components. Accessing your blackjack casino account through no download software platforms is not the smartest choice, particularly on public and open Wi-fi networks.

Both Flash and Java software platforms have proved vulnerable to security attacks, so even playing from a private computer on public Wi-fi networks can invite disaster if any savvy hackers are lurking. The security limitations of Java and Flash software platforms are unfortunate since no-download casino games applets would otherwise be ideal for use on public computers, with their frequent restrictions on downloading and installing programs.

Recommended Games