;; This file contains excerpts from the textbook Concrete ;; Abstractions: An Introduction to Computer Science Using Scheme, by ;; Max Hailperin, Barbara Kaiser, and Karl Knight, Copyright (c) 1998 ;; by the authors. Full text is available for free at ;; http://www.gustavus.edu/+max/concrete-abstractions.html ;; Chapter 14: Object-Oriented Programming ;; 14.5 An Application: Adventures in the Imaginary Land of Gack (define-class 'wizard auto-person-class '() '()) (class/set-method! wizard-class 'act (lambda (this) (let ((place (wizard/place this))) (let ((scrolls (filter scroll? (place/contents place)))) (if (and (not (null? scrolls)) (not (eq? place chamber-of-wizards))) (begin (wizard/take this (car scrolls)) (wizard/move-to this chamber-of-wizards) (wizard/lose this (car scrolls))) (auto-person^act this))))))