Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to assign values to poker cards via code

Status
Not open for further replies.

Sintrigue

Programmer
Oct 3, 2004
2
US
Hello all,

I'm very new to Delphi, so any Any help with this would be appreciated. I am trying to write a simple game that will check the value of two poker cards and see if the third card is higher, lower, or between the two that are showing. The problem I am having is "shuffling" the card deck and assigning a value to each card. The value of each card would be set randomly. When that number is selected at random by the code, it would display the card. Unfortunately, this simple-sounding program is really giving me a brain ache.

Any help would be most appreciated.

Sintrigue
 
It is usually a good idea to define types or classes for the things your program is dealing with.
Code:
type
  TSuit = ( Club, Diamond, Heart, Spade );
  TFace = ( Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace );
  TCard = record
    suit: TSuit;
    face: TFace;
  end;
A pack of cards could be defined by the type TPack and consist of an array of TCard.
Code:
type
  TPack = array [ TSuit, TFace ] of TCard;
And the actual pack of cards could be declared by the variable pack:
Code:
var
  pack: TPack;
I'm not going to write all the code for you. Using these types try writing a procedure that will assign the 52 card values to pack and post it back this thread. The way you do this will indicate your level of Delphi / programming expertise so that any further help can be made at the right level. It will also demonstrate how much effort you are prepared to put into this project.


Andrew
Hampshire, UK
 
Thank you! I'll be working on this during the next week or so and will post the results. You've given me a great start, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top