| Share this post! | Vote this! |
|
When most of use began programming, we started looking for various
project ideas to try. I've noticed card games come up a lot, so let's
have a look at some ways to implement a card game. We will be focusing
on the core of many card games, the cards and the deck.
The Card class is fairly simple, although it can be done a number of ways. I've chosen to use numeric variables for the internal data about the suit and rank, which will get converted to strings via predefined arrays when they need to be outputed. This lets us easily compare the suits and ranks (see if they're equal or sequential), without trying to use strings to represent them internally. If we used strings, we'd have to use more...
The Card class is fairly simple, although it can be done a number of ways. I've chosen to use numeric variables for the internal data about the suit and rank, which will get converted to strings via predefined arrays when they need to be outputed. This lets us easily compare the suits and ranks (see if they're equal or sequential), without trying to use strings to represent them internally. If we used strings, we'd have to use more...




0 comments:
Post a Comment