Thursday, August 11, 2011

In Class Notes

Inheritance
Pimp My Ride: They take a crappy car and make it fancy.
Instead of building a whole car from scratch they inherit a Nissan Sentra and extend it to look differently by changing it's properties.

It is still the same Nissan Sentra.

Composition
Composition is an alternative to inheritance.
This is like taking the Nissan Sentra and attaching another gadget, like a popcorn machine or huge cinema display. Making the 2 pieces work together, but they do not share any properties. You are composing the 2 pieces together.


Polymorphism
Allows objects of different classes to have the same method but behave differently.
On the Nissan Sentra when you turn on the lights that is a functionality of the car, but that method can turn on the headlights and turn on a disco ball. So "turnOn" can result in different things being turned on.



No comments:

Post a Comment