Wave 4: add sequences/vectors/files chapters, 23 exercises, quiz3, finish ceremony, PCL table
This commit is contained in:
1 parent
77843402fa
commit
4675bd1106
76 files changed
+2505
-14
No files matched your search
@@ -0,0 +1,24 @@
|
||||
;;; CLOS 7: PRINT-OBJECT AND DEFAULT-INITARGS (solution)
|
||||
|
||||
(defstruct candy filling size)
|
||||
|
||||
(defclass point ()
|
||||
((x :initarg :x :accessor point-x)
|
||||
(y :initarg :y :accessor point-y))
|
||||
(:default-initargs :x 0 :y 0))
|
||||
|
||||
(defmethod print-object ((p point) stream)
|
||||
(print-unreadable-object (p stream :type t)
|
||||
(format stream "x=~a y=~a" (point-x p) (point-y p))))
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; Checks. Read them - they tell you what to aim for - but leave
|
||||
;;; them unchanged.
|
||||
;;; ------------------------------------------------------------------
|
||||
|
||||
(check-equal 'swirl (candy-filling (make-candy :filling 'swirl)))
|
||||
(check-equal 0 (point-x (make-instance 'point)))
|
||||
(check-equal 7 (point-x (make-instance 'point :x 7)))
|
||||
(check-equal "#<POINT x=3 y=4>"
|
||||
(with-output-to-string (s)
|
||||
(princ (make-instance 'point :x 3 :y 4) s)))
|
||||
Reference in new issue
Block a user