public class Hangman { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("test string: (this is the answer) "); String ans = console.next();
String guess = ""; for (int i = 0; i < ans.length(); i++) { guess += "_"; }
while (!guess.equalsIgnoreCase(ans)) { System.out.println("Current status: " + guess ); System.out.print("Guess a letter: "); char letter = console.next().charAt(0); for (int i = 0; i < ans.length(); i++) { if (ans.charAt(i) == letter) { guess = guess.substring(0,i) + letter + guess.substring(i+1,ans.length()); } } } } }
all data structures are pure functional, structual sharing uses pure functional lazy static range adapters imlementation of the unique applicative and promptChar is trivial and left as an exercise to the reader
Sorry for being a brainlet, but in the last if, it's for replacing underscore with the correct character, right? But I don't quite get how this line works: guess = guess.substring(0,i) + letter + guess.substring(i+1,ans.length());
Zachary Jenkins
Nvm, I think I get it.
Hudson Allen
She's so cute
Samuel Garcia
Yeah, I wish that was me.
Alexander Allen
>sets ans to "_"
Cooper Ortiz
>her >she
Gavin Sanchez
Enough with this shitty meme
Hunter Bell
it's literally a male character, though
Jace Butler
It is a male character, you can look at the penis here . The whole traps aren't gay meme thing needs to die, it turns too many people into faggots.
I do login with Google but seriously fuck off I don't feel like logging in right now just to view a single God damn image especially on that cockblock roadblock shithole of a website, pixiv is pathetic bullshit
all data structures are pure functional, structual sharing uses pure functional lazy static range adapters imlementation of the unique applicative and promptChar is trivial and left as an exercise to the reader