Question: Implement InfixExpression class that is used to create and instantiate expressions in infix notations as objects. This class has one string attribute expression which holds
Implement InfixExpression class that is used to create and instantiate expressions in infix notations as objects. This class has one string attribute expression which holds the value of the expression. For example, AB is a possible value of such expression. Make sure to define that attribute as a private attribute and add setter and getter for it using decorators. You are also required to add the following instance methods to your class:
updateexpressionself operator, expression where operator is a character and expression is a string which represents another expression. The method should not return anything, rather it should update the expression of the InfixExpression object. Precisely, it should set the expression of the InfixExpression object to
be leopre where le is the expression of the object, op is operator, and re is expression.
Example
Let e be an InfixExpression whose expression has the value ABC Then
eupdateexpressionD updates the expression of the infix expression e to be ; and
eupdateexpressionDEF updates the expression of the infix expression e to be
converttopostfixself that uses the class Stack to return a string which is the expression in postfix notation. You have to consider only the following five arithmetic operators: CA ; respectively. Then
econverttopostfix "ABC;
e converttopostfix ABC; and
econverttopostfix "ABC
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
