Skip to main content

Timeline for Simple Blackjack implementation

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Apr 13, 2017 at 12:40 history edited CommunityBot
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Jul 22, 2015 at 13:20 comment added radarbob enum are type-safe - it is not just an integer. it has specific members - it cannot be just any "integer". enum members can be given explicit values so cardValue.TWO = 2 - you do not need to fuss with "offsets" because TWO is first in the list. enum members can be grouped, so you can easily make a "face card" group. enum are easy to use and really make switch statements clean and clear: it avoids all the ifing/elseing convolution in your code.
Jul 22, 2015 at 13:11 comment added radarbob isBlackJack() is a face card plus an ace. By contrast TwentyOne is any card combination that adds to 21, 'natch. If a Card knows that it is a face card, or not, then isBlackJack() becomes virtually trivial. If a Hand is the collection of cards held by a player then adding up the total value is a natural thing to do. I don't see how this has nothing to do with the game. If not why have it? If a Hand is where the players cards/had is, then here is where we must calculate the hand's value. In OOP a class is responsible for itself.
Jul 22, 2015 at 10:14 comment added dabadaba I delegated returning the value of a Hand to Blackjack instead of Hand because I was thinking in Hand as a more generic class that has nothing to do with the game. It's the rules of the game that define what value a hand has, and that's why handValue() is a method of the Blackjack class. How is isBlackjack() so complex and how would using enum help?
Jul 21, 2015 at 22:15 history edited radarbob CC BY-SA 3.0
added 177 characters in body
Jul 21, 2015 at 22:08 history answered radarbob CC BY-SA 3.0