I'm not really sure what's going on. It's come a long way from where it was, but it still doesn't function. The point of this exercise is to have a user guess "your favorite state" from a list of predetermined states. The user only gets three guesses, and then the program stops.
import java.io.*;
import java.util.*;
class stateHelper {
public static void getUserInput() {
ArrayList<String> stateList = new ArrayList<String>();
stateList.add("Georgia");
stateList.add("Hawaii");
stateList.add("Arizona");
stateList.add("New York");
stateList.add("Montana");
Scanner scan = new Scanner(System.in);
String userInput = scan.next();
System.out.println("Guess my favorite state: ");
//loop three times
int num = stateList.size();
for (int i = 0; i < num ; i++) {
// if state is in line, print you guessed it
String st = stateList.get(i);
System.out.println(st);
/*if (userInput.equals(stateList.get(i))) {
System.out.println("It is a hit.");
}
}
if (!userInput.equals(stateList.get(i))) {
System.out.println("It is a miss.");
} */
}
/*
System.out.println(stateList.get(0)+
stateList.get(1)+stateList.get(2)+stateList.get(3)+
stateList.get(4));
*/
}
}