Package memely

Interface Expression


public interface Expression
An immutable data type representing an image expression, as defined in the PS3 handout.

PS3 instructions: this is a required ADT interface. You MUST NOT change its name or package or the names or type signatures of existing methods. You may, however, add additional methods, or strengthen the specs of existing methods. Declare concrete variants of Expression in their own Java source files.

  • Method Details

    • parse

      static Expression parse​(String input)
      Parse an expression.
      Parameters:
      input - expression to parse, as defined in the PS3 handout
      Returns:
      expression AST for the input
      Throws:
      IllegalArgumentException - if the expression is syntactically invalid.
    • toString

      String toString()
      Overrides:
      toString in class Object
      Returns:
      a parsable representation of this expression, such that for all e:Expression, e.equals(Expression.parse(e.toString()))
    • equals

      boolean equals​(Object that)
      Overrides:
      equals in class Object
      Parameters:
      that - any object
      Returns:
      true if and only if this and that are structurally-equal Expressions, as defined in the PS3 handout
    • hashCode

      int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      hash code value consistent with the equals() definition of structural equality, such that for all e1,e2:Expression, e1.equals(e2) implies e1.hashCode() == e2.hashCode()