Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-advanced-reader.ss" "lang")((modname |40.2|) (read-case-sensitive #t) (teachpacks ((lib "guess-gui.ss" "teachpack" "htdp") (lib "guess.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp") (lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "guess-gui.ss" "teachpack" "htdp") (lib "guess.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp") (lib "draw.ss" "teachpack" "htdp")))))
4 (define (make-coord x y)
5 (local ((define x0 x)
6 (define y0 y)
7 (define (service-manager msg)
8 (cond
9 [(equal? msg 'x) x0]
10 [(equal? msg 'y) y0]
11 [(equal? msg 'set-x) (lambda (new-x) (set! x0 new-x))]
12 [(equal? msg 'set-y) (lambda (new-y) (set! y0 new-y))])))
13 service-manager))
15 (define (coord-x acoord)
16 (acoord 'x))
17 (define (coord-y acoord)
18 (acoord 'y))
19 (define (coord-x! acoord new-x)
20 ((acoord 'set-x) new-x))
21 (define (coord-y! acoord new-y)
22 ((acoord 'set-y) new-y))
23 (define acoord (make-coord 4 5))
24 (coord-x acoord)
25 (coord-y acoord)
26 (coord-x! acoord 3)
27 (coord-x acoord)
28 (coord-y! acoord 1)
29 (coord-y acoord)
31 (define (make-boyfriend name hair eyes phone)
32 (local ((define name0 name)
33 (define hair0 hair)
34 (define eyes0 eyes)
35 (define phone0 phone)
36 (define (service-manager msg)
37 (cond
38 [(symbol=? msg 'name) name0]
39 [(symbol=? msg 'hair) hair0]
40 [(symbol=? msg 'eyes) eyes0]
41 [(symbol=? msg 'phone) phone0]
42 [(symbol=? msg 'set-name) (lambda (new-name) (set! name0 new-name))]
43 [(symbol=? msg 'set-hair) (lambda (new-hair) (set! hair0 new-hair))]
44 [(symbol=? msg 'set-eyes) (lambda (new-eyes) (set! eyes0 new-eyes))]
45 [(symbol=? msg 'set-phone) (lambda (new-phone) (set! phone0 new-phone))])))
46 service-manager))
47 (define (boyfriend-name aboyfriend)
48 (aboyfriend 'name))
49 (define (boyfriend-hair aboyfriend)
50 (aboyfriend 'hair))
51 (define (boyfriend-eyes aboyfriend)
52 (aboyfriend 'eyes))
53 (define (boyfriend-phone aboyfriend)
54 (aboyfriend 'phone))
55 (define (boyfriend-name! aboyfriend new-name)
56 ((aboyfriend 'set-name) new-name))
57 (define (boyfriend-hair! aboyfriend new-hair)
58 ((aboyfriend 'set-hair) new-hair))
59 (define (boyfriend-eyes! aboyfriend new-eyes)
60 ((aboyfriend 'set-eyes) new-eyes))
61 (define (boyfriend-phone! aboyfriend new-phone)
62 ((aboyfriend 'set-phone) new-phone))
64 (define Aaron (make-boyfriend 'Aaron 'dark-brown 'black 646))
65 (boyfriend-name! Aaron 'Arone)
66 (boyfriend-hair! Aaron 'black)
67 (boyfriend-eyes! Aaron 'gray)
68 (boyfriend-phone! Aaron 545)
69 (boyfriend-name Aaron)
70 (boyfriend-hair Aaron)
71 (boyfriend-eyes Aaron)
72 (boyfriend-phone Aaron)