home *** CD-ROM | disk | FTP | other *** search
- // This is an example of inheritance
-
- class finance (cash) {
-
- receive(amount,source) {cash=cash+amount;
- inc[source]=inc[source,0]+amount;
- return "ok";}
- spend(amount,reason) {if(amount>cash) return "Insufficient funds";
- cash=cash-amount;
- exp[reason]=exp[reason,0]+amount;
- return "ok";}
- totalrec(source) {return inc[source,0];}
- totalspent(reason) {return exp[reason,0];}
- cashonhand() {return cash;}};
-
- class deduct_class (cash;deductible) : finance {
- init() {deductible = 0;}
- spend_deduct(amount,reason) {deductible = deductible + amount;
- spend(amount,reason);}
- spend_for_deduct(amount,reason,deduct) {deductible = deductible + deduct;
- spend(amount,reason);}
- total_deduct() {return deductible;}};
- end
-