Thursday, November 03, 2005

i never really got to update. sorry.

after linked lists, we had the rest of OOP. Abstraction, inheritance and polymorphism. All in 4 weeks. These series of lectures i really like, i've done these so many times that i have a script for each lecture.

For abstraction i always demonstrate with the Stack class and what happens to the stack if we manipulate the internal variables. Then a real life example: we dont really need to open up a TV to make it work, in fact we shouldnt.

For Inheritance its class Car, class Taxi extends Car and class FXTaxi extends Taxi. Also, class ElectricFan, class IndustrialElectricFan extends ElectricFan, class DesktopElectricFan... etc... A lot of examples of typecasting.

For polymorphism, its always the Employee class with an annualsalary() method, with subclasses Temporary, Casual and Permanent, each overriding annualsalary() due to different tax values. Showing how a single array of Employees can still handle the different annualsalary().

A nice example that i recently got was class LivingCreature with method move() which is overridden by subclasses like class Human, class Horse, class Bird.

then i had class diagrams. and a recitation of which are legal code (superclass reference -> subclass object, which are legal parameters to this method, typecasting etc). and now all these were the basis for their next and final exam.

0 Comments:

Post a Comment

<< Home