Question: PQ 0 3 a . Create an Abstract class called BinaryOperation, which has two operands, one operator. ( example: 4 + 5 the operands:
PQa Create an Abstract class called BinaryOperation, which has two operands, one operator. example: the operands: and operator:
b Create abstract methods int compute void and void printresult void in BinaryOperation. Also create necessary attributes, etc.
c Create classes extending this abstract class namely: AddBinaryOperation, SubBinaryOperation, MulBinaryOperation and DivBinaryOperation, which does addition, subtraction, multiplication, and division in the compute method.
d Create another class called BinaryEquationParser which has a static method with signature BinaryOperation parseBinaryOpString String binOpString
i This method parses the user input which is a string like and then it creates the appropriate instance in this case AddBinaryOperation and populates operands, operator, etc. It returns the instance.
e Create another class called BinaryMain which only has the main method.
i Take user input like and print the result. In this case, the result is
ii In main method, you will make a call ONLY to the parseBinaryOpString in the BinaryEquationParser and call compute and printresult appropriately.
Note: In total, this part will have a total of classes including the abstract class
Part Do this in a new file called VariableArityMain.java by copying the code from Part and modifying the classes as necessary
a The new abstract class will be called VariableArityOperation
i As the name suggest, it should support operation on more than two integers
ii Max up to integers Hint: you can use an array
b For simplicity sake, you can assume that we will only operate on positive integers and we dont need to support mixed expressions ie the variable arity operation only need to work for or and not
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
