MODEL MASTER
AN OBJECT-ORIENTED SPREADSHEET FRONT-END

Making spreadsheets safer

Contents Previous Next

MM company example - inheritance and code reuse

We can go on to make two companies, giving different initial values to each.

object company
    attributes
        incomings : real
        outgoings : real
        profit    : real
    where
        profit[t] = incomings[t] - outgoings[t].

object bogo_rexx is_a company
    where
        incomings[0] = 10000 &
        (t>0) incomings[t] = incomings[t-1]*1.1 &
        outgoings[0] = 5000 &
        (t>0) outgoings[t] = outgoings[t-1]*1.5.


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

Now both bogo_rexx and jiffco inherit the same attributes and formulae from company. But they then add different new formulae.

The definition of company could be stored in a library file for use by any program. See how easy it is to reuse code.

 


Contents Previous Next

Copyright © 1998 J Ireson-Paine. All rights reserved