CS61A_fa99_mt2 - CS 61A Midterm#2 Fall 1999 CS61A Fall 1999 Midterm#2 Problem#1(3 Points What will Scheme print in response to the following

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS61A Fall 1999 Midterm #2 Problem #1 (3 Points) What will Scheme print in response to the following expressions? If an expression produces an error message, you may just say "error"; you don't have to provide the exact text of the message. If the value of an expression is a procedure, just say "procedure"; you don't have to show the form in which Scheme prints procedures. Also, draw a box and pointer diagram, of the value produced by each expression . (cons (cons 3 4) (list 3 4)) (append '((3 4)) '(5 6)) (list 3 (list 4 5)) Problem #2 (4 Points) Consider this object class: (define-class (echoer) (instance-vars (last 'first-time)) (method (echo it) (let ((result last)) (set! last it) result))) (a) Demonstrate what this class does by filling in the blanks in the following interaction: > (define e (instantiate echoer)) > (ask e 'echo 'foo) __________________________________ > (ask e 'echo 'baz) __________________________________ (b) Create a new class called rewarder with an instantiation variable secret-word , with echoer as its parent class. A rewarder should handle echo messages just like an echoer, except that if the argument to the message is the secret word, it should instead return the sentence (You win $50) . Your solution must not copy the body of the echo method from the echoer class, but must instead rely on inheritance from its parent class. CS 61A, Midterm #2, Fall 1999 course, semester/yearexam # CS61A Fall 1999 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Problem #3 (4 points) In this question we want a simulation of automobiles (class auto ) and junkyards (class junkyard ).
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/23/2010 for the course CS 61A taught by Professor Harvey during the Fall '08 term at University of California, Berkeley.

Page1 / 5

CS61A_fa99_mt2 - CS 61A Midterm#2 Fall 1999 CS61A Fall 1999 Midterm#2 Problem#1(3 Points What will Scheme print in response to the following

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online