
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Practice Visitor Pattern
Modify the Mathematical Interpreter in Java (Mij) to “pretty print” the expressions rather than evaluate them. For example, here is a sample run of the program (user input shown in italics):
int ( 2*sin(x), x,0,2 *Pi) int(2 * sin(x), x, 0, 2 * Pi) 3(y-(3)/sin( ( Pi ) ))+(4z ) 3 * (y – 3 / sin(Pi)) + 4 * z
Fulfill the following requirements in formatting the output.
Be careful with parentheses. Consider the following two expressions:
Fill in the code for the Formatter class to use a visitor pattern and correctly output the formatted expressions.