Class XYCoordinate

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable

    public class XYCoordinate
    extends java.lang.Object
    implements java.lang.Comparable, java.io.Serializable
    Represents an (x, y) coordinate.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double x
      The x-coordinate.
      private double y
      The y-coordinate.
    • Constructor Summary

      Constructors 
      Constructor Description
      XYCoordinate()
      Creates a new coordinate for the point (0.0, 0.0).
      XYCoordinate​(double x, double y)
      Creates a new coordinate for the point (x, y).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.lang.Object obj)
      Compares this instance against an arbitrary object.
      boolean equals​(java.lang.Object obj)
      Tests this coordinate for equality with an arbitrary object.
      double getX()
      Returns the x-coordinate.
      double getY()
      Returns the y-coordinate.
      int hashCode()
      Returns a hash code for this instance.
      java.lang.String toString()
      Returns a string representation of this instance, primarily for debugging purposes.
      • Methods inherited from class java.lang.Object

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

      • x

        private double x
        The x-coordinate.
      • y

        private double y
        The y-coordinate.
    • Constructor Detail

      • XYCoordinate

        public XYCoordinate()
        Creates a new coordinate for the point (0.0, 0.0).
      • XYCoordinate

        public XYCoordinate​(double x,
                            double y)
        Creates a new coordinate for the point (x, y).
        Parameters:
        x - the x-coordinate.
        y - the y-coordinate.
    • Method Detail

      • getX

        public double getX()
        Returns the x-coordinate.
        Returns:
        The x-coordinate.
      • getY

        public double getY()
        Returns the y-coordinate.
        Returns:
        The y-coordinate.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this coordinate for equality with an arbitrary object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object (null permitted).
        Returns:
        A boolean.
      • hashCode

        public int hashCode()
        Returns a hash code for this instance.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        A hash code.
      • toString

        public java.lang.String toString()
        Returns a string representation of this instance, primarily for debugging purposes.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string.
      • compareTo

        public int compareTo​(java.lang.Object obj)
        Compares this instance against an arbitrary object.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        obj - the object (null not permitted).
        Returns:
        An integer indicating the relative order of the items.