On May 28, 11:49 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> On Wed, 28 May 2008 13:41:13 -0700, pek <kimwl...@gmail.com> wrote:
> > I'm about to create a simple card game and I'm not sure about what
> > classes should I create for the cards. I know a Card has a Rank (King,
> > Queen, Jack, 10....) and a Suit (Spades, Clubs, Hearts and Diamonds)
> > but the problem comes when I want to introduce Jokers and Tramp cards.
> > A Joker doesn't have a Suit (or a Rank, depending on how you look at
> > it).
>
> > Currently I have a Card class that takes two enumerations, a Suit
> > enumeration and a Rank enumeration. For the Joker I simply agreed to
> > always be a card with a Rank of Joker and a Suit of Spades. But that
> > just doesn't seem right. And I can't think of a way to create a
> > hierarchy of card classes.
>
> Well, you could just add another suit to your enumeration: "no suit", or
> "joker suit" or whatever you want to call it.
>
> I never heard of a "Tramp Card" so I don't know what would be most
> appropriate for that. Even a "trump card" is usually some specific card
> within the standard 52, and so is defined by the rules, not the card
> itself.
>
> Pete
Yes, I agree. trump card usually depends on the rules of a game. In my
game, a trump card is a card with a Rank of Trump (a special rank) and
a specific Suit (a standard suit - either spades or clubs etc.). So
creating a Trump card wasn't difficult.
As for Jokers. I changed it to always be Joker (Suit) Joker (Rank).
But I'm not sure if this is right. A stupid question crossed my mind:
What if I wanted to create a standard deck of 52 cards with 2 Red
Jokers and 2 Black Jokers (as is the case of a usual deck of cards)?
Does this mean that I have to have a Suit of RED_JOKER and
BLACK_JOKER? Isn't this a little overkill?
Thanks for your answers