next up previous contents index
Next: Class `library' part 1 Up: 3rd example of object Previous: Class `reader'   Contents   Start

Class `book'


(define make-book
  (lambda(atitle anauthor)
    (define title atitle)
    (define author anauthor)
    (define owner anauthor)
    (define holder anauthor)
    (define base-object (make-base-object))
;
    (define get-title
      (lambda()
        title))
;
    (define get-author
      (lambda()
        author))
;
    (define get-owner
      (lambda()
        owner))
;
    (define get-holder
      (lambda()
        holder))
;
    (define change-owner
      (lambda(new-owner)
        (define owner new-owner)))
;
    (define change-holder
      (lambda(new-holder)
        (define holder new-holder)))
;
    (define display
      (lambda()
        (print "book:")
        (print title)
        (print "by:")
        ((author 'who-are-you))
        (print "owner:")
        ((owner 'who-are-you))
        (print "holder:")
        ((holder 'who-are-you))
        (print "end-of-book")))
;
    (define self
      (lambda(msg)
        (if (equal msg 'get-title)
            get-title
            (if (equal msg 'get-author)
                get-author
                (if (equal msg 'get-owner)
                    get-owner
                    (if (equal msg 'get-holder)
                        get-holder
                        (if (equal msg 'change-owner)
                            change-owner
                            (if (equal msg 'change-holder)
                                change-holder
                                (if (equal msg 'display)
                                    display
                                    (base-object msg))))))))))
     self))



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz