I would give them labs that can later be reused for polymorphism. For example, introduce class signatures for Apple
,Banana
,Cake
,Dinner. Then you say that they need to implement a system of a Dinner
Dinner`. Then you say that they need to implement a system of a Dinner
:
public class Dinner{
//store the banana objects and apple objects
// (you can say that an array is useful here, as the dinner can't contain 20,000 apples.
//and also a collection of cake objects
...
}
And ask them to implement a system which allows the creation (which means they would have to write a constructor) of a Dinner
. Then they should write methods for the Dinner
object, so that one can add apples, bananas and cakes to the diner (this can be tricky; they'd need to keep an index for the arrays) and methods for when a customer orders a cake etc.
This assignment covers objects, including composition (no pun intended) and methods etc.