Similar Threads

Of course you will most probably need other methods, but I am sure you can figure them out yourself. Review the other classes too. We can do this in one step, if we want. Maybe I just have to learn more. You can run your game in a BlackJackGame class, which should maintain the game loop which would call other classes to deal a hand, get input, check end condition and apply results, after which it deals the next hand. Cannot retrieve the latest commit at this time. Please use your own brain.

Dchoc Cafe Blackjack (320x240) Nokia C5 Java Game

Your Answer

This method is setting card to your cards variable. Suppose you called addCard 3 times, then 0, 1 and 2 iteration of the loop in addHand will be ok but iteration 3 will through exception because cards[3] is null. 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.

Java simple BlackJack, java. I don't know why. NullPointerException, and the console points to my this "addHand" method: The exact error is: It depends on how you initialize the Hand.

Where does addCard Card actually get called? Could you add the code for your. Java Devil 7, 7 23 This indicates that there is problems else where in your code though. Also note that this should not be used as a fix. Using that second debug, I immediately get the else line. But sometimes I don't get it. Well there lies your problem, Look into your code where you are adding the cards to the hand!

But again, the results are unpredictable. Make sure you properly add cards. Mohayemin 3, 3 18 How to create a hand class for BlackJack java [closed] Ask Question.

This is my Card class below. I have tried nothing because honestly I dnt know what to do. Then try and come back when you have. I just need to know what logic should be in the hand class. Please use your own brain. Stack Overflow is not a site where you can make requests to implement code for you. I don't get the problem. You have your card class. Each hand has 2 cards. Create Class, which will contain for example ArrayList hand.

Maple Ridge Casino Opening

Leave a Reply