Question: Consider the object - oriented implementation of the Core interpreter with classes such as Stmt , SS , etc. corresponding, respectively, to , , etc.
Consider the objectoriented implementation of the Core interpreter with classes such as Stmt SS etc. corresponding, respectively, to etc. For this problem, you have to show how you can use subtype polymorphism in the implementation of the Stmt class, with classes such as Assign, If corresponding to the various alternative types of statements being derived classes of the Stmt class. Each of the methods, Parse, Print, and Execute, of Stmt will be an abstract or in C terminology, pure virtual method. Write the pseudocode for Stmt as well as the code for the If and Loop classes. Write your pseudocode in Java. Note that Stmt may be a Java interface rather an abstract class. Hint: You will have to modify the SS class, corresponding to since it is the Parse method of that class which will construct a Stmt object. But, in fact, you cannot construct such an object given that there are abstract methods in Stmt Thinking about how to address this problem will help you answer the question. A second hint: Although you cannot construct a Stmt object, you can construct an Assign object or an If object, etc. The Print and Execute methods should be straightforward.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
