(uiop:define-package :solar-short/class (:export #:book #:display-haiku #:next-haiku) (:import-from :asdf)) (in-package :solar-short/class) (defclass book () ((haikus :initform (list "Old brackets~%laying forgotten~%spring anew." "The water drop~%falling on the cracked ground~%bounces away." "Striving for more~%time for contentment~%is gone.")) (current :initform 0))) (defmethod display-haiku ((obj book) stream) (with-slots (haikus current) obj (format *error-output* "Refreshing display, current is ~a" current) (format stream (nth current haikus)))) (defmethod next-haiku ((obj book)) (with-slots (haikus current) obj (if (= current (- (length haikus) 1)) (setf current 0) (incf current))))