Enum Class Direction

java.lang.Object
java.lang.Enum<Direction>
za.co.wethinkcode.robots.domain.Direction
All Implemented Interfaces:
Serializable, Comparable<Direction>, Constable

public enum Direction extends Enum<Direction>
This enum encodes the cardinal directions of the world.

Note the encoding below, as it also stores the ordinals of the directions

  1. North represents an increase in Y plane
  2. East represents an increase in the X plane
  3. South represents a decrease in the Y plane
  4. West represents a decrease in the X plane
  • Enum Constant Details

  • Method Details

    • values

      public static Direction[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Direction valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getDeltaX

      public int getDeltaX()
      Return the change in the X axis that this direction represents
      Returns:
      the change in X
    • getDeltaY

      public int getDeltaY()
      Return the change in the Y axis that this direction represents
      Returns:
      the change in Y
    • getSymbol

      public String getSymbol()
      Returns:
      String representation of the symbol
    • turnLeft

      public Direction turnLeft()
      Returns:
      move an ordinal left
    • turnRight

      public Direction turnRight()
      Returns:
      move an ordinal right