Basically, the game goes like so-
User types a word they want player to guess (I've done this)
each letter in the word is displayed by "-"'s (I've done this)
Player guesses a letter in the word (I've done this)
Check guessed letter with each position in the word (I've done this)
Replace "-" for the letter per correct position (Stuck here....)
here's my code:
import java.util.*;
public class Hangman
{
public static void main(String[]args)
{
Scanner kybd = new Scanner(System.in);
int guesses = 0;
System.out.print("Enter a word to be guessed: ");
String word = kybd.nextLine();
for (int i = 1; i <= word.length(); i++)
{
System.out.print("-");
}
System.out.println("");
System.out.println("");
System.out.print("Enter a letter to be guessed: ");
String letter = kybd.nextLine();
char letterchar = letter.charAt(0);
for (int i = 1; i <= word.length(); i++)
{
if (letterchar == word.charAt(i))
{
//TRIED EVERTYTHING I COULD THINK OF.. ANY IDEAS? T_T
}
}
}
}
Thank you