CSC 216 F09/polymorphism4: Difference between revisions
No edit summary |
(→Is-a) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== | == Background == | ||
Polymorphism is having one class take multiple different forms of objects. This allows it to reference itself and objects of other classes easily. | Polymorphism is having one class take multiple different forms of objects. This allows it to reference itself and objects of other classes easily. | ||
Line 5: | Line 5: | ||
== Is-a == | == Is-a == | ||
This is a rule that checks to see if you are allowed to use polymorphism on the class in reference to another. For example car is-a drivable so | This is a rule that checks to see if you are allowed to use polymorphism on the class in reference to another. For example car is-a drivable so car is able to do what a drivable can do,however drivable is-not-a car so drivable cannot do what car can. | ||
== Props == | |||
Just need a few pieces of paper for each team | |||
== The Game == | == The Game == |
Latest revision as of 02:20, 19 December 2009
Background
Polymorphism is having one class take multiple different forms of objects. This allows it to reference itself and objects of other classes easily.
Is-a
This is a rule that checks to see if you are allowed to use polymorphism on the class in reference to another. For example car is-a drivable so car is able to do what a drivable can do,however drivable is-not-a car so drivable cannot do what car can.
Props
Just need a few pieces of paper for each team
The Game
Split the group into 4 groups of players. This game is going to be played by the teacher (or whoever is directing the learning exercise to give a topic (a broad topic is best). For example "Living Things" now every group has to come up with a thing that inherits from "Living Thing" and then another thing that inherits from that etc. Make a list of 5 things .However if any groups have the same thing inherited than that point is not counted for any team that has it. An example five things would be...
Topic:Living Things
Mammal
Platypus
Heart
Cell
Atom
Now if another team had
Topic:Living Things
Animal
Mammal
Primate
Human
Woman
The point mammal would be discounted for both teams.
Also any point that is not a valid inheritance is obviously discounted. The group with the most points after 5 rounds wins.
The number of groups , things inherited , and rounds could change based on how many people there are this is just a recomendation. It also needs to be played with groups of 3+ because groups of 2 would always tie.
Acknowledgments
This exercise was created by Armando Velez