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

*/

public class Negative extends ArithmeticExpression{
//Constructor
  public Negative(ArithmeticExpression var1){
    this.a = var1;
  }
  public Value evaluate(){
    if(!(this.a instanceof ArithmeticExpression)){
      return null;
    }
    if(this.a == null){
      return null;
    }

    Value test01 = this.a.evaluate();
    Value negative01 = new IntegerValue(((IntegerValue)test01).intEvaluate()*-1);
    return negative01;
  }
}