home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
ddjmag
/
ddj8706.arc
/
TELLOLST.JUN
< prev
next >
Wrap
Text File
|
1987-05-05
|
4KB
|
135 lines
Listing 1. Inheritance in SCOOPS
; (C) Copyright 1987 Ernest R. Tello
(define-class artifact
(instvars material weight purpose cost)
(options
(gettable-variables material weight purpose cost)
settable-variables
inittable-variables))
(define-class transport-means
(instvars medium time-range power-source)
(mixins artifact)
(options
(gettable-variables medium time-range power-source)
settable-variables
inittable-variables))
(define-class transport-vehicle
(instvars load-capacity length max-speed)
(mixins artifact transport-means)
(options
(gettable-variables load-capacity length max-speed)
settable-variables
inittable-variables))
(define-class passenger-vehicle
(instvars capacity safety dining facilities)
(mixins artifact transport-means transport-vehicle)
(options
(gettable-variables capacity safety dining facilities)
settable-variables
inittable-variables))
(define-class water-transport-vehicle
(classvars ( body-name 'hull) (dof 2) (dangers 'sink ) (advantages 'relaxing ))
(mixins artifact transport-means transport-vehicle passenger-vehicle)
(options
(gettable-variables dof dangers)
settable-variables
inittable-variables))
(define-class surface-vessel
(instvars #-decks #-masts #-engines )
(mixins artifact transport-means transport-vehicle passenger-vehicle water-transport-vehicle)
(options
(gettable-variables #-decks #-masts #-engines )
settable-variables
inittable-variables))
(define-class ship
(instvars
x-position y-position x-velocity y-velocity mass)
(mixins surface-vessel)
(options
(gettable-variables x-position y-position x-velocity y-velocity mass)
settable-variables
inittable-variables))
(define-method (ship speed) ()
(sqrt (+ (expt x-velocity 2)
(expt y-velocity 2))))
(define-method (ship direction) ()
(atan y-velocity x-velocity))
(define-class ocean-liner
(instvars company launched homeport tons )
(mixins ship)
(options
(gettable-variables company launched homeport tons )
settable-variables
inittable-variables))
(define ship1
(make-instance ship
'x-position 100
'y-position 150
'x-velocity 30
'y-velocity 40
'mass 100))
(compile-class artifact)
(compile-class transport-means)
(compile-class transport-vehicle)
(compile-class passenger-vehicle)
(compile-class water-transport-vehicle)
(compile-class surface-vessel)
(compile-class ship)
(compile-class ocean-liner)
Listing 2. Multiple Inheritance in SCOOPS
; (C) Copyright 1987 Ernest R. Tello
(define-class business
(instvars name location industry business-type size year-founded ownership-type gross-sales costs market-share)
(options
(gettable-variables name location industry business-type size year-founded ownership-type gross-sales costs market-share)
settable-variables
inittable-variables))
(define-method (business calc-net-gain) (gross-sales costs)
(- gross-sales costs))
(define-class adversary
(instvars aggressiveness allies goals common-goals strengths weaknesses)
(options
(gettable-variables aggressiveness allies goals common-goals strengths weaknesses)
settable-variables
inittable-variables))
(define-class competitor
(mixins business adversary))
(compile-class business)
(compile-class adversary)
(compile-class competitor)
(define your-business (make-instance business))
(define competitor-1 (make-instance competitor))