; "points1.oo"  -- uses setters & getters (note points.oo) -- KenD

(require 'yasos)

;;----------------
;; point interface
;;----------------

(define-predicate POINT?)  ;; answers #f (false) by default
(define-access-operation X)
(define-access-operation Y)


;;---------------------
;; point implementation
;;---------------------

(define (MAKE-POINT <x> <y>)
  (object
     ((POINT? self) #t) ;; yes, this is a point object
     ((X self) <x>)
     ((Y self) <y>)
     (((SETTER X) self val) (set! <x> val) <x>)
     (((SETTER Y) self val) (set! <y> val) <y>)
     ((SIZE self) 2)
     ((PRINT self port)
      (format port "#<point: ~a ~a>" (x self) (y self)))
) )

;;-----------------------------
;; 3D point interface additions
;;-----------------------------

(define-access-operation Z)


;;------------------------
;; 3D point implementation
;;------------------------

(define (MAKE-POINT-3D <x> <y> <z>)
   (object-with-ancestors ( (a-point (make-point <x> <y>)) )
      ((Z self) <z>)
      (((SETTER Z) self val) (set! <z> val) <z>)
      ;; override inherited SIZE and PRINT operations
      ((SIZE self) 3)
      ((PRINT self port)
       (format port "#<3D-point: ~a ~a ~a>" (x self) (y self) (z self)))
)  )


;;			--- E O F "points1.oo ---