Class Position


  • public class Position
    extends java.lang.Object
    Represents a position in 2d.
    • Constructor Detail

      • Position

        public Position​(int x,
                        int y)
        Create a new 2d position.
        Parameters:
        x - Coordinated on the x-axis
        y - Coordinated on the y-axis
    • Method Detail

      • next

        public Position next​(Vector vector)
        Add a vector to the position.
        Parameters:
        vector - 2d vector with x and y coordinates.
        Returns:
        New position which represents the result of adding of the vector.
      • nextX

        public Position nextX​(int x)
        Add a int on the x axis.
        Parameters:
        x - Int to add to the current position.
        Returns:
        New position which represents the result of adding of the int on x axis.
      • nextY

        public Position nextY​(int y)
        Add a int on the y axis.
        Parameters:
        y - Int to add to the current position.
        Returns:
        New position which represents the result of adding of the int on y axis.
      • previousX

        public Position previousX​(int x)
        Remove a int on the x axis.
        Parameters:
        x - Int to remove to the current position.
        Returns:
        New position which represents the result of removing of the int on x axis.
      • previousY

        public Position previousY​(int y)
        Remove a int on the y axis.
        Parameters:
        y - Int to remove to the current position.
        Returns:
        New position which represents the result of removing of the vector.
      • previous

        public Position previous​(Vector vector)
        Remove a vector to the position.
        Parameters:
        vector - 2d vector with x and y coordinates.
        Returns:
        New position which represents the result of removing of the int on y axis.
      • getX

        public int getX()
        Get x coordinate.
        Returns:
        x coordinate.
      • getY

        public int getY()
        Get y coordinate.
        Returns:
        y coordinate.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object