(defclass ship ()
((latitude :type real)
(longitude :type real)
(x-velocity :type real)
(y-velocity :type real)) )
(defmethod speed ((s ship))
(with-slots (s)
(sqrt (+ (expt x-velocity 2)
(expt y-velocity 2))) ))
(defmethod speedup ((s ship))
(with-slots (s)
(setf x-velocity (* x-velocity 2))
(setf y-velocity (* y-velocity 2))
s ))
In this example, a method speedup is defined; with frames, this was not possible because speedup is not associated with a slot. The frame example showed range restrictions on the values of latitude and longitude; the object representation doesn't handle this.
Contents    Page-10    Prev    Next    Page+10    Index