# RandomStringChooser - Part A

Each coding exercise has its own folder. Open its `.java` file and press **Run** to try it. **Run Tests** checks every graded exercise in this lesson at once.

The following is a free response question from 2016. It was question 1 on the exam. You can see all the free response questions from past exams at [Past AP CSA Exams](https://www.savemyexams.com/ap/computer-science/college-board/a/past-papers/).

**Question 1.** This question involves the implementation and extension of a `RandomStringChooser` class.

**Part a.** A `RandomStringChooser` object is constructed from an array of non-null `String` values. When the object is first constructed, all of the strings are considered available. The `RandomStringChooser` class has a `getNext` method, which has the following behavior. A call to `getNext` returns a randomly chosen string from the available strings in the object. Once a particular string has been returned from a call to `getNext`, it is no longer available to be returned from subsequent calls to `getNext`. If no strings are available to be returned, `getNext` returns `"NONE`.

The following code segment shows an example of the behavior of `RandomStringChooser`.

```java
String[] wordArray = {"wheels", "on", "the", "bus"};
RandomStringChooser sChooser = new RandomStringChooser(wordArray);
for (int k = 0; k < 6; k++)
{
   System.out.println(sChooser.getNext() + " ");
}
```

One possible output is shown below. Because `sChooser` has only four strings, the string `"NONE` is printed twice.

```
bus the wheels on NONE NONE
```

## Try and Solve It

Write the entire `RandomStringChooser` class. Your implementation must include an appropriate constructor and any necessary methods. Any instance variables must be `private`. The code segment in the example above should have the indicated behavior (that is, it must compile and produce a result like the possible output shown). Neither the constructor or any of the methods should alter the parameter passed to the constructor, but your implementation may copy the contents of the array.

### Exercise 1

Complete the `RandomStringChooser` class.

> Open the `01-codeRandomStrChooserA` folder and edit `Main.java`. Press **Run** to try it; **Run Tests** checks it (2 tests). Name the class, then rename the file to match.
