Structure "woodboard":
(defstruct woodboard
(size 'twoXfour)
(length 8)
(strength 'medium)
)
Structure "balsa" inherits from "woodboard":
(defstruct (balsa (:include woodboard (strength 'light))))
Class "board":
(defclass board ()
((size :accessor board-size :initarg :size :initform 'twoXfour)
(length :accessor board-length :initarg :length :initform 8)
(strength :accessor board-strength :initarg :strength :initform 'medium)
)
)
Class "balsaboard" has "board" as a superclass:
(defclass balsaboard (board)
((strength :initform 'light)))
Create an instance of woodboard:
> (setf b1 (make-woodboard))
Access the strength of b1:
> (woodboard-strength b1) --> MEDIUM
Create an instance of balsa:
> (setf b2 (make-balsa))
Values of fields for b2:
b2: size = twoXfour, length = 8, strength = light
Create an instance of class "balsaboard":
> (setf b3 (make-instance 'balsaboard))
Get the value of b3's strength:
> (board-strength b3) --> LIGHT