package edu.bloomu.ch5a;

import java.util.concurrent.ThreadLocalRandom;

/**
 * Outputs the name of an animal selected at random from a set of six possibilities. Two
 * different conventions for indenting an if-else chain are illustrated.
 *
 * @author Drue Coles
 */
public class RandomAnimals {

    public static void main(String[] args) {
        ThreadLocalRandom rand = ThreadLocalRandom.current();

        // Following the ordinary convention for indenting nested blocks, a chain of
        // if-else statements would drift significantly to the right.
        int die = rand.nextInt(1, 7);
        if (die == 1) {
            System.out.println("GOPHER");   
        } else {
            if (die == 2) {
                System.out.println("GRIVET");
            } else {
                if (die == 3) {
                    System.out.println("IGUANA");
                } else {
                    if (die == 4) {
                       System.out.println("OCELOT");
                    } else {
                        if (die == 5) {
                            System.out.println("QUOKKA");
                        } else {
                            System.out.println("WOMBAT");
                        }
                    }
                }
            }
        }

        // Conventional indentation for an if-else chain avoids code drift.
        if (die == 1) {
            System.out.println("GOPHER");
        } else if (die == 2) {
            System.out.println("GRIVET");
        } else if (die == 3) {
            System.out.println("IGUANA");
        } else if (die == 4) {
            System.out.println("OCELOT");
        } else if (die == 5) {
            System.out.println("QUOKKA");
        } else {
            System.out.println("WOMBAT");
        }
    }
}