Advertisement
Guest User

Untitled

a guest
Jun 9th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.59 KB | None | 0 0
  1. (defclass water ()())
  2.  
  3. (defclass chocolate (water)
  4.   ((sugar
  5.     :initarg :sugar
  6.     :initform 5
  7.     :reader get-sugar
  8.     :accessor set-sugar
  9.     :documentation "Sugar for hot chocolate")))
  10.  
  11. (defclass cafe (water)
  12.   ((sugar
  13.     :initarg :sugar
  14.     :initform 3
  15.     :reader get-sugar
  16.     :accessor set-sugar
  17.     :documentation "Sugar for hot cafe")))
  18.  
  19. (defclass dinner (chocolate cafe) ())
  20.  
  21. (defgeneric serving-drink (dinner)
  22.   (:documentation "Serving the dring for the dinner"))
  23.  
  24. (defmethod serving-drink (cup dinner)
  25.   (format t "The level of sugar is: ~d~%" (get-sugar cup)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement