MODEL MASTER
AN OBJECT-ORIENTED SPREADSHEET FRONT-END

Making spreadsheets safer

Contents Previous Next

MM company example - adding attributes via inheritance

Now let's try taking workforce costs into account.

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

object company_and_workers is_a company
    attributes
        workforce     : integer
        average_salary: real
    where
        outgoings[t] = workforce[t]*average_salary[t].

object parkinsons is_a company_and_workers
    where
        workforce[0] = 100 &
        (t>0) workforce[t] = workforce[t-1]*2 &
        average_salary[0] = 12000 &
        (t>0) average_salary[t] = average_salary[t-1]*1.5 &
        incomings[0] = 1000 &
        (t>0) incomings[t] = incomings[t-1] * 1.1.

There are two stages of inheritance here. The first adds attributes and behaviour; the second just adds behaviour.

Both could be done in one stage. However, we might want to use company_and_workers in other programs.

 


Contents Previous Next

Copyright © 1998 J Ireson-Paine. All rights reserved