Sign in to follow this  
  • entries
  • comments
  • views

Tactics (and Advice)

Sign in to follow this  


Well, after some of the people over at #gamedev looked at my code and pointed out at TON of "design errors" (such as the use of BAD_SUIT, BAD_VALUE cards as sentinels for the end of the deck), they told me to mostly scrap the entirety of CardDeck, and change some of the details of Card.h - Card itself was fine - by tkaing out the BAD_ values in the enums, and JOKER in Suits.

So now I'm rewriting CardDeck as an inheritance tree, with base class Pile and derived classes Deck and Hand - yes, this wasn't my idea, which is why it sounds so good. Honestly, I haven't had much experience at all with inheritance, but if I can pull this off, I'll be able to do my next project much more smoothly. It's a big redesign of cConsole.

I've got a design problem in my plan for cConsole though. I'm going to have a ConsoleBase class that contains the core Console info (like the buffer), but I need a way for both of its derived classes to be able to access the the exact same info in it.

For example, if ConsoleBase has derived classes ConsoleInput and ConsoleOutput (not the names I'll use, just an example), and an ConsoleInput is created, it should initialize the ConsoleBase class if it isn't already. Then, if ConsoleOutput is instatiated, it should just use the ConsoleBase info that's already there, rather then creating another instance.

Could that be solved with static members in ConsoleBase? The members would have to be private to keep the derived classes from inheriting them, though. That would keep the derived classes from using them at all. =| Would it work if I made the derived classes friends of the base class? Is that even allowed?

Please comment and help =|
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now