hey im having the same problem with my code im a beginner in a programing class and have been trying to figure it out for days im trying to build a game of hangman.
please help..class TestGuessList { private char guessList; public static void main (String []args) { GetInput input = new GetInput(); GuessList list = new GuessList(); char guessList = ' '; int turns=5; for (int f=0;f<5;f++) { boolean done = false; System.out.println("You have " + turns + " turns remaining "); while (done == false) { input.setUserInput(); guessList=input.getUserInput(); while (list.inGuessList(guessList)==true) { System.out.println("This letter has already been guessed"); } done = false; } turns--; System.out.print("the letters that you have already guessed and added to you ignore list are: "); list.print(); System.out.println("\n"); } } } the method class is this public class GuessList// Class is responsible for insuring the letter guess is valid. { private char[] list; //Creates a private array character variable called list. public GuessList()// Creates a public method called GuessList. { char[] list = new char [0];//Creates an array called list. } public boolean inGuessList(char c)//Creates a public boolean method called inGuessList. { boolean duplicate=false;//Creates a boolean called duplicate and sets it to false. for(int x=0; x<list.length;x++)/*Creates a for loop with int x and sets it less then the length of * list and not equal to duplicate.*/ { if(list[x] == c )// Ifs statement for if list is equal to c. { duplicate = true;//Makes duplicate true. return duplicate;//Returns duplicate. } } return false; } public void print()//Print method. { System.out.println("The letters you have guessed are ");//Prints the letters guessed to the user. for(int i = 0;i<list.length;i++)//Creates a for loop for int i. { System.out.println(list[i] + " ");//Prints list[i]. } } char[] getGuessList()//Creates an array method. { return list;//Returns the list. } public void addToGuessList(char guesses)//Creates a method called addToGuessList. { char[] list2 = new char [list.length +1];//Creates a second longer array. for(int t = 0; t<list.length; t++)//Creates a for loop less the the size of list. { list2[t]=list[t];//Makes list2[t] equal to list[t]. } list2[list.length] = guesses;//Makes list2[list.length] equal to guesses. list=list2;//Makes list equal to list2. } }