// Arup Guha
// 4/28/2018
// Solution to 2016 AP Computer Science FRQ Question 1A - RandomStringChooser

import java.util.*;

public class RandomStringChooser {

	// We only need one of these for the class, since we just need to be able to
	// generate a random number for each object, but don't need a new Random object to do that.
	private static Random r = new Random();

	private ArrayList<String> choices;

	// Put everything from the array items into our ArrayList.
	public RandomStringChooser(String[] items) {
		choices = new ArrayList<String>();
		for (String x: items)
			choices.add(x);
	}

	public String getNext() {

		// No more strings to return, so we return this.
		if (choices.size() == 0) return "NONE";

		// Returns a random index into our ArrayList choices.
		int idx = r.nextInt(choices.size());

		// Choose the idx item and remove it from the list, then return it.
		String s = choices.remove(idx);
		return s;
	}

	// A little test.
	public static void main(String[] args) {
		String[] list = {"hello", "bob", "this", "is", "a", "test"};
		RandomStringChooser mine = new RandomStringChooser(list);
		for (int i=0; i<10; i++)
			System.out.print(mine.getNext()+" ");
		System.out.println();
	}
}