Blackjack visual basic code
I'm currently making a blackjack game for my project in school in Visual Basic. In blackjack, when you have aces (value initially 11) their value turns to 1 when the total value of the cards is > In code, this would just take away 10 for every ace. I'm stuck on this. This is the code I have (that doesn't work). Basic strategy is not enough! We get emails from people all the time talking about how they downloaded our blackjack charts, took them to a casino, and won some money. That’s great news for them, but it could have easily gone the other way. Basic strategy cannot overcome the house edge even if you get lucky with it from time to time. This is the snippet BlackJack on FreeVBCode. The FreeVBCode site provides free Visual Basic code, examples, snippets, and articles on a variety of other topics as well.
Subscribe to RSS
Sign up or log in Sign up using Google. ReadLine ; Why is this here? Face, dealerHand[dealerHand. WriteLine "amount is illegal. Also try to seperate your class rather than having multiple internal classes. With that, all this code would simplify to: return cards.
VBScript Blackjack Game - Basic
Is unshuffled deck ever useful for anything? If not, you might want to call Shuffle at the end of Initialize , which will also avoid having to call Shuffle after Initialize , which happens several times in your code. You should use the Card object initializer to set Value too. Using Math. Min , that could look like this:. This looks like you don't want List , you want Stack. With that, all this code would simplify to:. What's the logic behind this? Why are you accepting strings like 10 0?
And if you did intend that, what's the reason for that Trim? Replace will already remove all spaces, including those at the start and end of the string and I don't think any other whitespace characters which is what the parameterless overload of Trim removes make sense here. I don't think your logic for handling aces is sufficient.
If I understand the rules correcty, even an ace that's not among the first two cards can be counted as 11 and even ace that is among the first two can be counted as 1. Don't leave commented out code from previous versions of your code behind. After you know the commented out code is no longer useful, remove it completely. You're already computing amountLost to display it, you should also use it to modify chips , since it will make your code more DRY:. Both Deck and Hand overrides should take advantage of Card.
I have to alter this in order for more than one player to be available. Do I change something in the Player class? Or do I create a new class for all Players? I am on the right track? Here is the code so far:. Also try to seperate your class rather than having multiple internal classes.
It makes an easier read and makes navigation easier. Learn more. I have created a Black Jack game in c for one player. How can I create it for two or more players? Ask Question. Asked 4 years, 1 month ago. Active 4 years, 1 month ago. Viewed 4k times. Next 0, deck. Value, card. WriteLine "Bust! WriteLine "Draw! WriteLine "It's a draw! Write "Please enter your name: " ; player.
Write "Please enter a name for the dealer: " ; dealer. Write "Hit or Stick? WriteLine ; Console. Write "Do you want to play again? Leighton Blackburn Leighton Blackburn 11 1 1 silver badge 3 3 bronze badges. Is this your homework? It's an extension task. My homework was to do the 5 card trick, so I wanted to do something trickier. Tomaltach Tomaltach 7 7 silver badges 23 23 bronze badges.
What do you mean by separate my class? Add a new class in the project. Look at the updated answer. It will make each file smaller and to the point. The Player class will have all the properties the player should have.
Наслаждайся подборкой классных снимков и расслабляйся. Молоденькая Алиса прошла долгий путь, создавая модельную внешность, и, добившись желаемого, стремится поддерживать в идеальном состоянии спортивную фигуру.
Зайдя на кухню, молодая прошмандовка решила попробовать себя в качестве стриптизерши и начала все с себя снимать. 471.