home *** CD-ROM | disk | FTP | other *** search
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; File name: tools.s
- ;
- ; original XLISP-version:
- ;
- ; Author: Tim Mikkelsen
- ; Description: Object-oriented example program
- ; Language: XLISP 2.0
- ;
- ; Date Created: 10-Jan-1988
- ; Date Updated: 2-Apr-1989
- ;
- ; (c) Copyright 1988, by Tim Mikkelsen, all rights reserved.
- ; Permission is granted for unrestricted non-commercial use.
- ;
- ; port to XScheme:
- ;
- ; Language: Xscheme 0.28
- ;
- ; Date Created: 23-Feb-1992
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; Define the superclasses and classes
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;
- ; make TOOLS superclass
- ; with a different 'ISNEW method
- ; added methods are 'BORROW and 'RETURN
- ; class variables are NUMBER contains # of tool instances
- ; ACTIVE-LIST contains list of current objects
- ; instance variables are POWER list - (AC BATTERY HAND)
- ; MOVEABLE CAN-CARRY or CAN-ROLL or FIXED
- ; OPERATIONS list
- ; MATERIAL list - (WOOD METAL PLASTIC ...)
- ; PIECES list
- ; LOCATION HOME or person's name
- ;
-
- (set! tools (class 'new '(power
- moveable
- operations
- material
- pieces
- location)
- '(number active-list)))
- (tools 'answer 'isnew '()
- '((if (null? number) (set! number 1)
- (set! number (1+ number)))
- (set! active-list (cons self active-list))
- (set! location 'home)
- self))
- (tools 'answer 'borrow '(by-who)
- '((if (eq? location 'home) (set! location by-who)
- (display "you can't"))))
- (tools 'answer 'return '()
- '((if (eq? location 'home) (display "got it already")
- (set! location 'home))))
-
- ;
- ; make HAND-TOOLS class
- ; with a different 'ISNEW method
- ; new instance variable WEIGHT <number> of pounds
- ; the rest is inherited from TOOLS
- ;
-
- (set! hand-tools (class 'new '(weight) '() tools))
- (hand-tools 'answer 'isnew '(pow op mat parts w-in)
- '((set! power pow)
- (set! moveable 'can-carry)
- (set! operations op)
- (set! material mat)
- (set! pieces parts)
- (set! weight w-in)
- (send-super 'isnew)))
-
- ;
- ; make SHOP-TOOLS class
- ; with a different 'ISNEW method
- ; no new instance variables
- ; the rest is inherited from TOOLS
- ;
-
- (set! shop-tools (class 'new '() '() tools))
- (shop-tools 'answer 'isnew '(pow mov op mat parts)
- '((set! power pow)
- (set! moveable mov)
- (set! operations op)
- (set! material mat)
- (set! pieces parts)
- (send-super 'isnew)
- self))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ; Create instances of various tool classes
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (set! hand-drill (hand-tools 'new ; make an instance - HAND-DRILL
- '(ac)
- '(drill polish grind screw)
- '(wood metal plastic)
- '(drill drill-bits screw-bits buffer)
- '2.5))
-
- (set! table-saw (shop-tools 'new ; make an instance - TABLE-SAW
- '(ac)
- 'fixed
- '(rip cross-cut)
- '(wood plastic)
- '(saw blades fence)))
-
-
- (set! radial-arm (shop-tools 'new ; make an instance = RADIAL-ARM
- '(ac)
- 'can-roll
- '(rip cross-cut)
- '(wood plastic)
- '(saw blades dust-bag)))
-
-