Please note, this blog entry is from a previous course. You might want to check out the current one.
Lecture #3 is a demonstration of how to solve the previous assignment and adds new features to the Matchismo app by adding additional cards and a card-matching algorithm.
The code for this lecture is available at github.
The lecture as well as its slides (which include a complete walk through of the demo from the lecture) are available via iTunes called “3. Objective-C”.
Hey thanks for posting this!
Question: how does the program know at runtime which match function to use? I.e., between the match function in card class and the match function in playingcard class?
Thanks!
That’s the magic of object-oriented programming 😉
If a child class overrides a method, this method will be used. If not, the parent method is used. If you need the functionality of the parent method, you have to call the parent method from inside the child method.
Nevertheless, you might want to check out the Stanford course cs106a. It’s for free on iTunes (and you can find solutions to the assignments here as well: https://cs193p.m2m.at/tag/cs106a/ )
Thanks for your response – so to understand you correctly, calling match anywhere in cardMatchingGame would automatically call the match from the subclass?
(sorry if i’m being repetitive)
That’s the idea, but you should really have a look at the course I suggested, you will gain much more insight into object-oriented programming.
Merry Christmas