Package com.iizix

Class Position

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

    public class Position
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    A position with integers.
    Author:
    Christopher Mindus
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      intx
      The X position.
      inty
      The Y position.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      Position()
      Constructs a position initialized to 0,0.
      Position​(int x, int y)
      Constructs and initializes position.
      Position​(Position p)
      Constructs and initializes position.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static intcompare​(Position p1, Position p2)
      Compares to position by first X, then Y.
      booleanequals​(java.lang.Object o)
      Check for equality.
      inthashCode()
      Hash code.
      java.lang.StringtoString()
      Creates the string representation of this position.
      • Methods inherited from class java.lang.Object

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

      • x

        public int x
        The X position.
      • y

        public int y
        The Y position.
    • Constructor Detail

      • Position

        public Position()
        Constructs a position initialized to 0,0.
      • Position

        public Position​(int x,
                        int y)
        Constructs and initializes position.
        Parameters:
        x - The X position.
        y - The Y position.
      • Position

        public Position​(Position p)
        Constructs and initializes position.
        Parameters:
        p - The position to clone.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Check for equality.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - Another object.
        Returns:
        true if it's the same Position object values, false otherwise.
      • hashCode

        public int hashCode()
        Hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        Returns the hash code.
      • toString

        public java.lang.String toString()
        Creates the string representation of this position.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Position String as "className[x=NN,y=NN]".
      • compare

        public static int compare​(Position p1,
                                  Position p2)
        Compares to position by first X, then Y.
        Parameters:
        p1 - Position 1 (null allowed).
        p2 - Position 2 (null allowed).
        Returns:
        1 if p1 is "larger" than p2 (or p2 is null), -1 if "smaller" (or p2 is null), 0 if equal (both null).