import java.util.concurrent.ThreadLocalRandom;

/**
 * If you live in a popular vacation spot, one way to deal with unwelcome tourists is to
 * give them inaccurate information when they ask for directions. This program simplifies 
 * the process for locals by generating random responses that they can use when asked for 
 * driving directions.
 * 
 * @author Drue Coles
 */
public class Navigator {

    private static enum Direction {NORTH, EAST, SOUTH, WEST};
    
    public static void main(String[] args) {
        ThreadLocalRandom rand = ThreadLocalRandom.current();
        final int maxDist = 10;
        double miles = rand.nextDouble(0, maxDist);
        System.out.printf("Go straight for %.1f miles.%n", miles);
        
        // output a series of random turns and distances
        final int numTurns = 4;
        for (int i = 0; i < numTurns; i++) {
            Direction dir = randomDirection();
            miles = rand.nextDouble(0, maxDist);
            System.out.printf("Turn %s and drive %.1f miles.%n", dir, miles);
        }
        System.out.print("Your destination will be on the ");
        System.out.println(rand.nextBoolean() ? "left." : "right.");
        System.out.println("You can't miss it.");
    }
    
    /**
     * Returns one of the four Directions chosen at random. 
     */
    private static Direction randomDirection() {
        ThreadLocalRandom rand = ThreadLocalRandom.current();
        switch (rand.nextInt(4)) {
            case 0: return Direction.NORTH;
            case 1: return Direction.EAST;
            case 2: return Direction.SOUTH;
            case 3: return Direction.WEST;
            default: return null; // unreachable
        }
    }
}