CSC 216/s08/strive for happiness
Formatting Resources
Formatting Help Guide from MetaWiki
What is Polymorphism?
The problem
Describe what you are attempting to teach students by this exercise.
Polymorphism is derived from Greek, meaning "many forms". Therefore, in Java, polymorphism is using a super class variable to refer to a subclass object, the "many forms" of the super class variable. It is useful because interfaces and inheritance can be used more abstractly.
A game loosely based on "Let's Make A Deal" would be played to illustrate this abstraction.
Participants and props
5 students would participate in the front of the class.
The rest of the class would participate and be divided into 2 teams. Teams would be vying for "the prize". Incentive might be a victory trophy (cans of soda, candy bars, 1 extra point on the exam or homework).
Props would 8.5" x 11" paper with writing on it.
4 students would be each be holding 3 pieces of paper: 1 with a number on the "door" and another with code on it. The code would be hidden behind the "door numbered" piece of paper. The code would list the animal type. The last piece of paper would be a method.
What else do you need (e.g., old tennis ball, Powerpoint slides, software).
There may be a Powerpoint slide still up on the screen with the rules listed as a reminder.
The script
A game loosely based on "Let's Make A Deal" would be played.
Teams would be formed (6-7 people or rows of students) would see a walk-through of 1 person going through the motions of choosing 1 of 4 doors and seeing what's behind each of the doors.
Behind each door would be an animal. Each animal would have maybe 2 methods, such as talk() or daySleeper().
A follow up of the exercise would be that each team would be given a pile of scraps of paper with single lines of code (from the animal abstract interface example that was talked about) written on it. The lines of code would need to be ordered correctly in the shortest amount of time. Huge hints would have been given in the walk through, so students would have been needing to pay attention earlier.
Next exercise: each team would attempt to write the code in order to make the walk-through work in a specified/requested fashion from the Powerpoint slide listed on the overhead. For example: Make an animal that is a carnivore, talk.
Next exercise: Each group needs to write a main method for testing purposes to create a working action, specified by the overhead, from the code that was ordered together from the previous exercise. Perhaps there is a time limit....
So there are 3 timed exercises with 3 prizes for the winning team:
- candy bars (miniatures)
- 6-pack of soda (making it 1 can per person on the winning team)
- +1 point on next test or program