Is this nested class design ineffective for my Nested Deck class? design and implementation
Previous review of this project:Deck and Card classes and member-accessing with one header
Deck and Card classes and member-accessing with one header
I'm nearly finished with my deck of cards project, and this time I made changes to hide the CardCard
class by nesting it in the DeckDeck
class. I'm still getting correct results when displaying the deck. However, I do now realize that I can no longer maintain CardCard
objects outside the class. Instead, I have to call Card deal()
with a DeckDeck
object in order to retrieve a CardCard
, and I cannot store that CardCard
anywhere.
Does this render my design ineffective for this purpose? If so, how else can I maintain CardsCard
s outside the class while still preventing the user from directly constructing a CardCard
? Would a privateprivate
constructor (with CardCard
un-nested from DeckDeck
) be a better option?
Is this nested class design ineffective for my Deck class?
Previous review of this project:Deck and Card classes and member-accessing with one header
I'm nearly finished with my deck of cards project, and this time I made changes to hide the Card class by nesting it in the Deck class. I'm still getting correct results when displaying the deck. However, I do now realize that I can no longer maintain Card objects outside the class. Instead, I have to call Card deal()
with a Deck object in order to retrieve a Card, and I cannot store that Card anywhere.
Does this render my design ineffective for this purpose? If so, how else can I maintain Cards outside the class while still preventing the user from directly constructing a Card? Would a private constructor (with Card un-nested from Deck) be a better option?
Nested Deck class design and implementation
Previous review of this project:
Deck and Card classes and member-accessing with one header
I'm nearly finished with my deck of cards project, and this time I made changes to hide the Card
class by nesting it in the Deck
class. I'm still getting correct results when displaying the deck. However, I do now realize that I can no longer maintain Card
objects outside the class. Instead, I have to call Card deal()
with a Deck
object in order to retrieve a Card
, and I cannot store that Card
anywhere.
Does this render my design ineffective for this purpose? If so, how else can I maintain Card
s outside the class while still preventing the user from directly constructing a Card
? Would a private
constructor (with Card
un-nested from Deck
) be a better option?