;cad.lsp ;(unuse-package "CLOS") (defclass cad-object () ((x :accessor x :initform 0 :initarg :x) (y :accessor y :initform 0 :initarg :y))) (defmethod print-prop ((object cad-object)) (print "X is ") (print (x object)) (print "Y is ") (print (y object))) (defmethod get-prop ((object cad-object)) (print "gimmie the X value:") (setf (x object) (read)) (print "gimmie the Y value:") (setf (y object) (read))) (defclass rectangle (cad-object) ((height :accessor height :initform 1 :initarg :height) (width :accessor width :initform 1 :initarg :width))) (defmethod print-prop :after ((object rectangle)) (print "Height is ") (print (height object)) (print "Width is ") (print (width object))) (defmethod get-prop :after ((object rectangle)) (print "gimmie the Height:") (setf (height object) (read)) (print "gimmie the Width value:") (setf (width object) (read))) (defclass circle (cad-object) ((radius :accessor radius :initform 1 :initarg :radius))) (defmethod print-prop :after ((object circle)) (print "Radius is ") (print (radius object))) (defmethod get-prop :after ((object circle)) (print "gimmie the Radius:") (setf (x object) (read))) ;/////testing ;(setq r1 (make-instance `rectangle)) ;(get-prop r1) ;(print-prop r1) ;(setq c1 (make-instance `circle)) ;(get-prop c1) ;(print-prop c1)