CSC 216 F09/Interface
Interfaces
The Problem
This exercise is designed to teach students the basics behind the structure of an interface. By the end, they should be able to recognize when it is appropriate to organize and implement an interface for similar classes containing similar methods.
Participants and Props
- 3 volunteers
- Object cards
- 3 markers
- Whiteboard
The Script
Before the exercise begins, the instructor should have prepared multiple sets of 3 index cards. In every individual set, the index cards should have a single, drawable object written on it. All three of the objects in the set should be able to have a single adjective ending with the suffix "-able" used to describe.
If the index cards are prepared, three students will either volunteer or be called upon to go to the whiteboard. Once there, they will each be given an index card from the set, whereupon they shall draw the object written on their card.
When they are all done, the other students in the class should be prompted to guess what each of the pictures is supposed to be. These objects will represent java classes.
After they finish guessing, they should be asked to find a specific adjective which ends with the suffix "-able" that applies to all three of the objects. This will represent the name of an interface.
When they have found the word the instructor is looking for, they should then be asked to give any number of possible methods that apply to the interface and all three of the objects.
Index Card Suggestions:
Flyable:
- Plane
- Blimp
- Predator (Unmanned Aerial Vehicle)
Possible Methods
- Take-off
- Land
- Steer
Store-able:
- Treasure Chest
- Dumpster
- Hard drive
Possible Methods
- Lock/Unlock
- Add
- Remove
kick-able:
- Soccer ball
- Bucket
- Foot ball
Possible Methods
- Apply force
- Etc.