import java.util.Random;

/** 
 * RandomSeeds - Demo on Random Seeding.
 * using a random index value.
 * See Think Java page 48 or Page 111 for more info on Random class.
 * @author Alvin Chao
 * @version 10-22-18
 * I abided by the JMU Honor Code.
 */
public class RandomSeeds {

    /**
     * Main. 
     * @param args command line arguments.
     */
     
    public static void main(String[] args) {
        // Random Seed list for 10 items:
        long longseed = 0;
        Random rand = new Random(longseed);
        System.out.printf("Random Seed 1 for %d: ", longseed);
        for(int i = 0; i < 10; i++) {
            System.out.print(rand.nextInt(4) + " ");
        }
        System.out.println("\n");
        // Second run no new seed
        System.out.printf("Random Seed 2 for %d: ", longseed);
        for(int i = 0; i < 10; i++) {
            System.out.print(rand.nextInt(4) + " ");
        }
        System.out.println("\n");
        // Reset Random generator
        System.out.println("Reset the seed");
        rand = new Random(longseed);
        // Third run 
        System.out.printf("Random Seed 3 for %d: ", longseed);
        for(int i = 0; i < 10; i++) {
            System.out.print(rand.nextInt(4) + " ");
        }
        System.out.println("\n");
        // New Seed
        longseed = 5000;
        rand = new Random(longseed);
        // Fourth run 
        System.out.printf("Random Seed 4 for %d: ", longseed);
        for(int i = 0; i < 10; i++) {
            System.out.print(rand.nextInt(4) + " ");
        }
        System.out.println("\n");
    }
}
