// Return the new orientation based on the original orientation and its relative direction private static Orientation orientationOnDirection(Orientation original, Direction direction) { if (direction == Direction.AHEAD) { return original.clone(); } else if (direction == Direction.LEFT) { return original.relativeToLeft(); } else if (direction == Direction.RIGHT) { return original.relativeToRight(); } else { assert (false) : "Should not reach here"; } return null; }
private Direction getPreferedDirection( Orientation firstOrientation, Orientation secondOrientation) { Direction preferedDirection = Direction.NULL; if (firstOrientation.relativeToLeft().equals(secondOrientation)) { preferedDirection = Direction.LEFT; } else if (firstOrientation.relativeToRight().equals(secondOrientation)) { preferedDirection = Direction.RIGHT; } else { assert (false) : "Two Prefered Orientation should be adjacent"; } return preferedDirection; }