In the last lesson we were introduced to Inheritance which is a strategy we can use when classes display an IS-A relationship.
These designs are possible because each class inherits properties and methods from a superclass, .
A Hare is also an Animal.
It also has a name and a score property, and accessor and mutator methods as all other Animals have!
But, in one (or more) way, a Hare is different.
A Hare eats carrots and it can remember how many it has eaten!
This is reasonable. We cannot expect all Animals to be exactly the same.
So, given that a Hare IS-A Animal, how can we incorporate this difference into our design when we are utilising inheritance?
Click the exercises button and see if you can complete the challenges.
object
property
method
create an object/instance of a class
instantiate an object
encapsulate
access
mutate
abstraction
idesyntax file class instantiate constructor type propertymethod