public void takeGuess () throws IOException
{ temp=" ";
Hangman obj = new Hangman();
System.out.println ("Enter a character or type in 'hint' for a hint!");
DataInputStream input=new DataInputStream(System.in);
temp= input.readLine();
if (temp.length()==1)
{
guess=temp.charAt(0);
if ((guess >= 'a' && guess <='z') || (guess >='A' && guess <='Z'))
{System.out.println();}
else
{System.out.println ("Special symbols or numbers are not present in fruit names yet!" );
System.out.println ("Please give a correct input below");
obj.takeGuess();}
}
else if (temp.length()!=1)
{
if (temp=="hh")
System.out.println ("giveHint()");
else
{System.out.println ("Please give a correct single-character input below");
obj.takeGuess();}
}
System.out.println ( temp);
System.out.println (guess);
}
I wrote this piece of code but sadly it does not function. the value of guess does not update. Can someone please help me out. I'm an absolute newbie ( 12 yrs. old ). Please explain why this is happening and also please give the updated code if possible. :)