[an error occurred while processing this directive]

## cs150: Notes 23

#### Assignments Due

• Read before 17 March: Chapter 10
• Before Monday, 19 March: Read rest of GEB part I (Chapters 2-4 and 6-9, in addition to Chapters 1 and 5 you have already read). (There will be a short quiz in class on Monday, 19 March.)
• Friday, 23 March: Problem Set 6

Notes

```(define (make-number n)
(lambda (message)
(cond
((eq? message 'value) (lambda (self) n))
((eq? message 'add) (lambda (self other)

(define (ask object message . args) (apply (object message) object args))
```
Inheritance is using the definition of one class to make another class.
```(define (make-fraction numer denom)
(let ((super (make-number #f)))
(lambda (message)
(cond
((eq? message 'value) (lambda (self) (/ numer denom)))
((eq? message 'get-denominator) (lambda (self) denom))
((eq? message 'get-numerator) (lambda (self) numer))
(else (super message))))))

(define (make-fraction numer denom)
(make-subobject
(make-number #f)))
(lambda (message)
(cond
((eq? message 'value) (lambda (self) (/ numer denom)))
((eq? message 'get-denominator) (lambda (self) denom))
((eq? message 'get-numerator)   (lambda (self) numer))
(else #f)))))

(define (make-subobject super imp)
(lambda (message)

))
```
The class fraction inherits from number.
fraction is a subclass of number.
The superclass of fraction is number.

Which of the traced applications are from fraction and which are from number?
```> (ask half 'add half)
| #f
| #f
| #f
| #f
| #t
| |(eq? value value)
| |#t
| 1/2