ok i have 2 strings lets call it word = "hello" alpha = "abcdefg.... down to z" char current1 = " " char current2 = " "
ok now,
for (int x=0;x<word.length();x++) { boolean done = false; current1 = word.charAt(x); for (int y=0; y<alpha.length();y++) { current2 = alpha.charAt(y); if (current1 == current2) { System.out.print("*"); done = true; } } if (done = false) { System.out.print(current1) } }
basically, if the char is in the alpha string, it returns a *, as the char hasnt been guess... when a char from the word string is guessed, it is removed from the alpha string.
Hence, once both loops run, if the char in word isnt found in the alpha string then done should be false and the char in word is just written.
hence for example word = "hello" alpha = "all the alphabet letters, abcdefg" then out put works as, *****
but if i make it like word = "hello" alpha = "all but e, like abcdfghijklmn..." then the output is **** , i want it to be *e***
hence why i tried to use the boolean done, incase the char we are lookin for isnt done in the loop.