enum Dir {
  S, E, N, W;

  //note - to use a for loop with a Dir index you can write: for (Dir d : Dir.values())

  static Dir suc(Dir d) {
    switch (d) {
      case S:
        return E;
      case E:
        return N;
      case N:
        return W;
      case W:
        return S;
      default:
        return S;
    }
  }

  static char chr(Dir d) {
    switch (d) {

      case S:
        return 'S';
      case E:
        return 'E';
      case N:
        return 'N';
      case W:
        return 'W';
      default:
        return 'D';
    }
  }

  static Dir inv(Dir d) {
    switch (d) {

      case S:
        return Dir.N;
      case E:
        return Dir.W;
      case N:
        return Dir.S;
      case W:
        return Dir.E;
      default:
        return Dir.N;
    }

  }
}


 