Click here to Skip to main content
15,891,372 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: converting this code tot non-mfc Pin
Uma Mahes9-Dec-03 18:13
Uma Mahes9-Dec-03 18:13 
Generalmake a comparision with excel Pin
aguest9-Dec-03 11:23
aguest9-Dec-03 11:23 
Questionwhat is the .net equivalent of findwindow()? Pin
godzooky9-Dec-03 10:47
godzooky9-Dec-03 10:47 
Generalsystem.web namespace in managed c++ library Pin
godzooky9-Dec-03 9:04
godzooky9-Dec-03 9:04 
GeneralRe: system.web namespace in managed c++ library Pin
JWood9-Dec-03 15:01
JWood9-Dec-03 15:01 
GeneralObject oriented Programming (OOP) Pin
ZackyD9-Dec-03 8:46
ZackyD9-Dec-03 8:46 
GeneralRe: Object oriented Programming (OOP) Pin
Christian Graus9-Dec-03 9:59
protectorChristian Graus9-Dec-03 9:59 
GeneralRe: Object oriented Programming (OOP) Pin
Tim Deveaux9-Dec-03 10:20
Tim Deveaux9-Dec-03 10:20 
You can use a scheme to identify rank and suit by using div() on an range of integers from 0 to 51 (this is how the cards dll works - google for Cards.dll for tips on how a card can be represented) In this case you could wrap this up with a class with little more than an integer member and an overloaded member that would output the rank and suit.

Now then - what does a deck do? Well, it needs a number of cards, a way of shuffling them, and a way of doling one out - so, you might have a int GimmeACard() method, e.g.

A hand will need to RecieveACard(int) likewise.

The dealer (main.cpp) will need to:

have a deck to work with (for int GimmeACard())
have hands to be dealt to (with ReceiveACard(int))

Does this help? Note that the nice thing is that the details involved in the operations are hidden below the interfaces, leaving you with a nice little black box to work with. Take the case of the Deck class. It is free to worry about what type of randomization to use when the Shuffle() method is called. It takes care of knowing what cards are left in the deck after each one is doled out.

Your dealer can then just say:

// declare the object instances
Deck myDeck;
Hand myHand; // or make and array of pointers to hands and new 'em

// Shuffle the deck
myDeck.Shuffle(); // could take a seed parameter

// deal a card to a hand
myHand.RecieveACard(myDeck.GimmieACard());

Each .cpp file #includes its corresponding .h file.

Your main.cpp will #include the headers it needs, and when you instantate the objects they'll be ready for use. The linker will take care of tieing the files together - just make sure they're in the project.

Hope this helps - I'm just killing a little time here, having have had a bit of fun with this kind of thing in the past...
GeneralRe: Object oriented Programming (OOP) Pin
ZackyD9-Dec-03 11:09
ZackyD9-Dec-03 11:09 
GeneralObject Oriented Programming (OOP) Pin
ZackyD9-Dec-03 6:17
ZackyD9-Dec-03 6:17 
GeneralRe: Object Oriented Programming (OOP) Pin
valikac9-Dec-03 6:36
valikac9-Dec-03 6:36 
GeneralRe: Object Oriented Programming (OOP) Pin
ZackyD9-Dec-03 8:38
ZackyD9-Dec-03 8:38 
GeneralRe: Object Oriented Programming (OOP) Pin
David Crow9-Dec-03 7:05
David Crow9-Dec-03 7:05 
GeneralGetting 'MFCs' current directory Pin
Andy Latham9-Dec-03 6:10
Andy Latham9-Dec-03 6:10 
GeneralRe: Getting 'MFCs' current directory Pin
David Crow9-Dec-03 6:16
David Crow9-Dec-03 6:16 
GeneralRe: Getting 'MFCs' current directory Pin
Andy Latham9-Dec-03 6:29
Andy Latham9-Dec-03 6:29 
GeneralRe: Getting 'MFCs' current directory Pin
David Crow9-Dec-03 6:52
David Crow9-Dec-03 6:52 
GeneralRe: Getting 'MFCs' current directory Pin
valikac9-Dec-03 6:40
valikac9-Dec-03 6:40 
GeneralRe: Getting 'MFCs' current directory Pin
Andy Latham9-Dec-03 22:26
Andy Latham9-Dec-03 22:26 
GeneralRe: Getting 'MFCs' current directory Pin
valikac10-Dec-03 6:17
valikac10-Dec-03 6:17 
GeneralRe: Getting 'MFCs' current directory Pin
Andy Latham10-Dec-03 6:47
Andy Latham10-Dec-03 6:47 
GeneralRe: Getting 'MFCs' current directory Pin
valikac10-Dec-03 8:49
valikac10-Dec-03 8:49 
GeneralAbout Winamp's Plugin Visualiztion Pin
pmasknguyen9-Dec-03 5:44
pmasknguyen9-Dec-03 5:44 
GeneralRe: About Winamp's Plugin Visualiztion Pin
User 66589-Dec-03 6:46
User 66589-Dec-03 6:46 
GeneralRe: About Winamp's Plugin Visualiztion Pin
pmasknguyen9-Dec-03 21:45
pmasknguyen9-Dec-03 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.