Class NumberToken


  • public class NumberToken
    extends Token
    Represents a number (using double values). Using equals, a NumberToken object compares as true only to another NumberToken object with the same value

    a NumberToken is immutable, once created it doesn't change

    • Constructor Detail

      • NumberToken

        public NumberToken​(double value)
        Constructs a token representing value
        Parameters:
        value - the value of this number token
    • Method Detail

      • equals

        public boolean equals​(Object o)
        Overrides:
        equals in class Object
        Returns:
        true iff o is a NumberToken with same value
      • value

        public double value()
        Returns:
        the value of this token
      • toString

        public String toString()
        Description copied from class: Token
        Represents the token by its description
        Overrides:
        toString in class Token
        Returns:
        the token's description
      • isConstant

        public boolean isConstant()
        Description copied from class: Token
        Returns true if this token represents a constant, false otherwise
        Specified by:
        isConstant in class Token
        Returns:
        true iff this Token represents a constant
      • isFunction

        public boolean isFunction()
        Description copied from class: Token
        Returns true if this token represents a function, false otherwise
        Specified by:
        isFunction in class Token
        Returns:
        true iff this Token represents a function