my super class(abstract):
exp1.display
will display my resultexp1.evaluate
should return((1.2 * 4.2) + 4.2))
but it returns only(5.04 + 4.2)
I need
- help with my evaluate method and
- a test class but to test and see if the operations from my subclasses are working but im not sure how to do it.
.
abstract class arithmeticexpression {
public Double a;
public Double b;
arithmeticexpression(Double a, Double b)
{
this.a = a;
this.b = b;
}
public void display()
{
}
public double evaluation()
{
}
}
public class addition extends arithmeticexpression {
Double x;
Double y;
public addition(Double a, Double b)
{
super(a, b);
}
public void evaluation()
{
System.out.println(a + " + " + b);
}
public Double display()
{
return a + b;
}
}
// subclass of arithmeticexpression
public class multiplication extends arithmeticexpression {
public multiplication(Double a, Double b)
{
super(a, b);
}
public void evaluation()
{
System.out.println(a + " * " + b);
}
public Double display()
{
return a * b;
}
}
My main:
import java.util.Scanner;
public class main {
public static void main(String[] args) {
arithmetic exp1 = new addition(new multiplication(1.2,4.2).display(), 4.2);
exp1.display();
exp1.evaluation();
}
}