The exam that covers the Common Lisp material through Friday of this week is this coming Monday in EPS 108 from noon until 12:50 p.m. You may bring one 8.5 by 11 sheet of notes. The best way to practice for the exam is to work the daily exercises and to understand how to solve Program 1.
(defclass book ()
(
(pages :accessor pages)
(author :accessor author)
)
)
(setf my-book (make-instance 'book))
(setf (pages my-book) 200) (setf (author my-book) 'Melville)
(defmethod pretty-print ((abook book))
(format t "The author of the book: ~a~%" (author abook))
(format t "The number of pages: ~a~%" (pages abook))
)
(pretty-print my-book)
(defclass textbook (book)
(
(subject :accessor subject)
)
)
(defmethod pretty-print ((abook textbook))
(format t "Pages: ~a~%" (pages abook))
(format t "Author: ~a~%" (author abook))
(format t "Subject: ~a~%" (subject abook))
)
(setf nillson (make-instance 'textbook))
(setf (pages nillson) 513)
(setf (author nillson) 'nillson)
(setf (subject nillson) 'computer-science)
(pretty-print nillson) ;; calls the second version of pretty-print
(pretty-print my-book) ;; calls the first version
(pretty-print 100) ;; ERROR, neither version is applicable