CSE-8B / PA6 / starter / Product.java
Product.java
Raw
//File: Product.java
//Name: Trai Pham
//Date: 02/16/2020
//Course: CSE 8B
/**

*/

public class Product extends ArithmeticExpression{
  public Product(ArithmeticExpression var1, ArithmeticExpression var2){
    this.a = var1;
    this.b = var2;
  }
  public Value evaluate(){
    if(!(this.a instanceof ArithmeticExpression) ||
    !(this.b instanceof ArithmeticExpression)){
      return null;
    }
    if(this.a == null || this.b == null){
      return null;
    }
    Value test01 = this.a.evaluate();
    Value test02 = this.a.evaluate();
    Value product01 = new IntegerValue(((IntegerValue)test01).intEvaluate()*
    ((IntegerValue)test02).intEvaluate());
    return product01;
  }
}