Artifact f3ce88430d4b1a6c206ce1ba8c10141e5e47ab06cf1014ddfe614989b97c68da:
- File
psl-1983/util/object-test.sl
— part of check-in
[eb17ceb7f6]
at
2020-04-21 19:40:01
on branch master
— Add Reduce 3.0 to the historical section of the archive, and some more
files relating to version sof PSL from the early 1980s. Thanks are due to
Paul McJones and Nelson Beebe for these, as well as to all the original
authors.git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/historical@5328 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1117) [annotate] [blame] [check-ins using] [more...]
(BothTimes (load objects mathlib)) (defflavor ship ((x-position 0.0) (y-position 0.0) (x-velocity 0.0) (y-velocity 0.0) ) () settable-instance-variables ) (setq s (make-instance 'ship)) (=> s x-position) (=> s y-position) (=> s x-velocity) (=> s y-velocity) (=> s describe) (=> s set-x-position 1.0) (=> s set-y-position 2.0) (=> s set-x-velocity 3.0) (=> s set-y-velocity 4.0) (=> s x-position) (=> s y-position) (=> s x-velocity) (=> s y-velocity) (=> s describe) (defmethod (ship speed) () (sqrt (+ (* x-velocity x-velocity) (* y-velocity y-velocity))) ) (=> s speed) (defmethod (ship speed) () (let ((x (=> self x-velocity)) (y (=> self y-velocity))) (sqrt (+ (* x x) (* y y))) )) (=> s speed) (defmethod (ship direction) () (if (= x-velocity 0.0) (if (< y-velocity 0.0) 270.0 90.0) (atanD (/ y-velocity x-velocity)) )) (=> s direction) (setq s1 (make-instance 'ship 'x-position 3.0 'y-position 3.5)) (=> s1 describe) (setq s2 (make-instance 'ship 'x-position 6.0 'y-position -6.0 'x-velocity 10.0 'y-velocity -10.0)) (=> s2 describe)