Record Class Num

All Implemented Interfaces:
Value

public record Num(double x) extends Record implements Value
Our internal representation of a number in the D0 language. See http://www.radford.edu/itec380/2022fall-ibarland/Project
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Num(double x)
    Creates an instance of a Num record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object that)
    Indicates whether some other object is "equal to" this one.
     
    final int
    Returns a hash code value for this object.
    static Num
    parse(Scanner s, String punctuation)
     
    Returns a string representation of this record class.
    double
    x()
    Returns the value of the x record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Num

      public Num(double x)
      Creates an instance of a Num record class.
      Parameters:
      x - the value for the x record component
  • Method Details

    • eval

      public Value eval()
      Specified by:
      eval in interface Value
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • parse

      public static Num parse(Scanner s, String punctuation)
    • equals

      public boolean equals(Object that)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      that - the object with which to compare
      Returns:
      true if this object is the same as the that argument; false otherwise.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • x

      public double x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component