Hey guys.
How may I implement a high/low card game using inheritance, any ideas out there? Sorry I am a bit of a newbie to all this stuff.
Help very much appreciated !
cloud21
0
Newbie Poster
Recommended Answers
Jump to PostPerhaps you could define a base class, called "Card" that has the rank values contained within it, as cards of all suits have a rank value. Then, you could define 4 derived classes, "SpadeCard", "HeartCard", "DiamondCard" and "ClubCard".
Good luck!
Jump to Post>Then, you could define 4 derived classes, "SpadeCard",
>"HeartCard", "DiamondCard" and "ClubCard".
You really think a class for each suit is necessary? Do you suggest making a separate class for each value too? :icon_rolleyes: There's not enough complexity in a standard deck of cards to justify inheritance, so perhaps the …
Jump to PostI agree, you could represent the suits with an enum; but since he was looking for a class/inheritance feature, I suggested that one. Certainly your approach works as well.
Jump to PostAdding inheritance for the sake of inheritance is silly. I'd argue that just throwing inheritance in wherever you can because the assignment requires it teaches you nothing about how to design good software.
All 16 Replies
jack1978
0
Newbie Poster
jack1978
0
Newbie Poster
cloud21
0
Newbie Poster
mcriscolo
47
Posting Whiz in Training
Narue
5,707
Bad Cop
Team Colleague
mcriscolo
47
Posting Whiz in Training
Narue
5,707
Bad Cop
Team Colleague
mvmalderen
2,072
Postaholic
mvmalderen
2,072
Postaholic
cloud21
0
Newbie Poster
Lerner
582
Nearly a Posting Maven
cloud21
0
Newbie Poster
jack1978
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
cloud21
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.