CSC 216/s08/strive for happiness: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 57: Line 57:
===The script===
===The script===


<p>A game loosely based on "Let's Make A Deal" would be played.</p>
The exercise will be introduced, and the props and instructions given to the class, which should take no more than 5 minutes. Each group will be given a stack of about 15 cards, and each group will have identical cards to each other group.
<p>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.</p>
<p>Behind each door would be an animal. Each animal would have maybe 2 methods, such as talk() or daySleeper().</p>
<p>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.</p>
<p>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.</p>
<p>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....</p>


<p>So there are 3 timed exercises with 3 prizes for the winning team:
The class will then be given 10-15 minutes to do about 20 exercises, based on the cards they are given.
<ol>
 
<li>candy bars (miniatures)</li>
After the exercise is concluded, the class will review the correct answers and discuss them for 10-15 minutes. The class will go over how the Animal superclass is analogous to the Object superclass in Java. They will also talk about how methods of a subclass override methods of the superclass, in the same way that the methods of the animals do.
<li>6-pack of soda (making it 1 can per person on the winning team)</li>
 
<li>+1 point on next test or program</li>
--[[User:Deswartz|Deswartz]] 17:37, 26 March 2008 (EDT)
</ol>
</p>

Revision as of 21:37, 26 March 2008

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.

Participants and props

The class will be divided into small groups of 3-5 people. Each group will receive a number of Animal Cards (explained below) and a list of exercises will be shown on the board.

An Action Card will be a small index card with a class definition and one or two methods. For example,

   public class Dog extends Quadruped {
       public void talk() {
           System.out.println("Woof");
       }
   }
   public class Quadruped extends Animal {
       public void walk() {
           System.out.println("Walk");
       }
   }
   public class Bird extends Animal {
       public void fly() {
           System.out.println("Fly");
       }
       public void talk() {
           System.out.println("Chirp");
       }
   }
   public class Owl extends Bird {
       public void talk() {
           System.out.println("Whoo");
       }
   }

An html page, powerpoint slide, or simply a part of the class notes will have a list of exercises for the groups to perform. For example,

   Bird B = new Owl();
   B.talk();
   Animal A = new Bird();
   A.talk();

The students will then write down the answers to all of these exercises based upon what is on their cards.

--Deswartz 17:31, 26 March 2008 (EDT)

The script

The exercise will be introduced, and the props and instructions given to the class, which should take no more than 5 minutes. Each group will be given a stack of about 15 cards, and each group will have identical cards to each other group.

The class will then be given 10-15 minutes to do about 20 exercises, based on the cards they are given.

After the exercise is concluded, the class will review the correct answers and discuss them for 10-15 minutes. The class will go over how the Animal superclass is analogous to the Object superclass in Java. They will also talk about how methods of a subclass override methods of the superclass, in the same way that the methods of the animals do.

--Deswartz 17:37, 26 March 2008 (EDT)