Question: CSE 341 This is the starter code: 3. Complete the Racket implementation except for intersection, which means skip for now additions to the intersect% class

CSE 341

CSE 341 This is the starter code: 3. Complete the Racket implementation

This is the starter code:

except for intersection, which means skip for now additions to the intersect\%class and, more importantly, methods related to intersection in other classes. Donot modify the code given to you. Follow this approach: - Everysubclass of geometry-expression\% should have a preprocess-prog method that takes no arguments

3. Complete the Racket implementation except for intersection, which means skip for now additions to the intersect\% class and, more importantly, methods related to intersection in other classes. Do not modify the code given to you. Follow this approach: - Every subclass of geometry-expression\% should have a preprocess-prog method that takes no arguments and returns the geometry object that is the result of preprocessing this. To avoid mutation, return a new instance of the same class unless it is trivial to determine that this is already an appropriate result. - Every subclass of geometry-expression\% should have an eval-prog method that takes one argument, the environment, which you should represent as a list of pairs: a Racket string (the variable name) in the car and an object that is a value in our language in the cdr. As in any interpreter, pass the appropriate environment when evaluating subexpressions. (This is fairly easy since we do not have closures.) To make sure you handle both scope and shadowing correctly: 3 - Do not ever mutate an environment; create a new environment as needed instead. - The eval-prog method in var\% is given to you. Make sure the environments you create work correctly with this definition. The result of eval-prog is the result of "evaluating the expression represented by this," so, as we expect with OOP style, the cases of OCaml's eval_prog are spread among our classes, just like with preprocess_prog. - Every subclass of geometry-value\% should have a shift method that takes two arguments dx and dy and returns the result of shifting this by dx and dy. In other words, all values in the language "know how to shift themselves to create new objects." Hence the eval-prog method in the shift % class should be very short. - Remember you should not use Racket features like is-a? or implementation?. - Analogous to OCaml, an overall program e would be evaluated via (send (send e preprocess-prog) eval-prog null). 3. Complete the Racket implementation except for intersection, which means skip for now additions to the intersect\% class and, more importantly, methods related to intersection in other classes. Do not modify the code given to you. Follow this approach: - Every subclass of geometry-expression\% should have a preprocess-prog method that takes no arguments and returns the geometry object that is the result of preprocessing this. To avoid mutation, return a new instance of the same class unless it is trivial to determine that this is already an appropriate result. - Every subclass of geometry-expression\% should have an eval-prog method that takes one argument, the environment, which you should represent as a list of pairs: a Racket string (the variable name) in the car and an object that is a value in our language in the cdr. As in any interpreter, pass the appropriate environment when evaluating subexpressions. (This is fairly easy since we do not have closures.) To make sure you handle both scope and shadowing correctly: 3 - Do not ever mutate an environment; create a new environment as needed instead. - The eval-prog method in var\% is given to you. Make sure the environments you create work correctly with this definition. The result of eval-prog is the result of "evaluating the expression represented by this," so, as we expect with OOP style, the cases of OCaml's eval_prog are spread among our classes, just like with preprocess_prog. - Every subclass of geometry-value\% should have a shift method that takes two arguments dx and dy and returns the result of shifting this by dx and dy. In other words, all values in the language "know how to shift themselves to create new objects." Hence the eval-prog method in the shift % class should be very short. - Remember you should not use Racket features like is-a? or implementation?. - Analogous to OCaml, an overall program e would be evaluated via (send (send e preprocess-prog) eval-prog null)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!