Please note, this blog entry is from a previous course. You might want to check out the current one.
Add a new MVC to your Matchismo solution from last week which plays a simple version of the card matching game Set. A good solution to this assignment will use object-oriented programming techniques to share a lot of code with your Playing Card-based matching game.
For convenience (and to confuse you), I followed the tasks of this assignment slightly out of order. But now, I should be back to the “correct” order.
As model, we need a set card and its deck. Create SetCard as subclass of Card and SetCardDeck as subclass of Deck.
As controller create SetCardGameViewController as subclass from CardGameViewController.
Finally as view, remove the second view controller (which came with the tab-bar controller). Duplicate the PlayingCardViewController link it to the tab-bar controller and change its class to SetCardGameViewController:
The playing-card tab should work like before. Selecting the set tab will work to, but as as soon as you click anything else, the app will crash … because the model and the view controller are still empty and derive their functionality from the generic parent function … and the card-matching-game class does not check for such a case … and crashes …
The complete code is available on github.