next up previous
Next: Adding attributes via inheritance
Up: MM company example
Previous: Adding behaviour via inheritance

Inheritance and code reuse

We mentioned earlier that MM allows specifications to be reused. Here is an example. We could, in the same program as bogo_rex, define another company:

object jiffco {
  inherits( company )
  incomings[0] = 10000 &
  (t>0) incomings[t] = incomings[t-1]*2.5 &
  outgoings[0] = 5000 &
  (t>0) outgoings[t] = outgoings[t-1]*0.9

Both companies inherit from company, but each adds its own distinct equations.

Jocelyn Ireson-Paine
Sat Nov 28 17:42:14 GMT 1998