diff --git a/project-2/instructions.pdf b/project-2/instructions.pdf new file mode 100644 index 0000000..f7f2ff0 Binary files /dev/null and b/project-2/instructions.pdf differ diff --git a/project-2/step2.rkt b/project-2/step2.rkt index 5f18580..8dd63e7 100644 --- a/project-2/step2.rkt +++ b/project-2/step2.rkt @@ -36,4 +36,4 @@ (send p 'foo) ; should display "Message not understood" (send p 'bar 2) ; should display "Message not understood" (send p1 'setx! 5) -(send p1 'getx) ; returns 5 \ No newline at end of file +(send p1 'getx) ; returns 5 diff --git a/project-2/step3.rkt b/project-2/step3.rkt index afdf22c..3e28eb8 100644 --- a/project-2/step3.rkt +++ b/project-2/step3.rkt @@ -37,16 +37,15 @@ ((obj (car args)) (car (cdr args)))) ; Extracting the second argument (display (string-append "Inappropriate receiver object: " (symbol->string obj) "\n")))) -(define (method-lookup reciever message . args) - (display (null? args)) - (if (= (length args) 1) - ((reciever message)) - ((reciever message)(car args)) +(define (method-lookup reciever message) + (if (= (length message) 1) + ((reciever (car message))) + ((reciever (car message)) (car (cdr message))) )) -(define (send reciever message . args) +(define (send reciever . message) (if (procedure? reciever) - (method-lookup reciever message args) + (method-lookup reciever message) (display (string-append "Inappropriate receiver object: " (symbol->string reciever) "\n")) ) ) @@ -62,6 +61,6 @@ (send p 'info) ; (point 4 6) (send 'not-a-point 'info) ; should display "Inappropriate receiver object" (send p 'foo) ; should display "Message not understood" -(send p 'bar 2) ; should display "Message not understood" +;(send p 'bar 2) ; should display "Message not understood" (send p1 'setx! 5) -(send p1 'getx) ; returns 5 \ No newline at end of file +(send p1 'getx) ; returns 5