So my question is, how do I go about making characters combine with the question marks to show progress? Say the person guessed the letter 'l' in the code below. How do I make the progress line output "??ll? ???l?" ? Also, we are not to ACTUALLY replace ?'s with the correctly guessed letter with some code we haven't learned about yet. I just have no idea how to make the program check the secret word for correct user-input letters.
Here's the code so far:
import java.util.Scanner;
public class wordguess {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
{
String answer = ("hello world"); // a pre-set word, will be user-input later
String unfinished = ("????? ?????"); // ?'s used to hide the word
String progress = (""); // add characters to ?'s to show progress
String wrong = (""); // display guessed incorrect letters
System.out.print("Enter a letter to find out what " + unfinished + " is: ");
String try1 = in.next(); // store first try, unneeded??
if (try1.length() != 1) // make sure it is one letter
{
System.out.println("Try again, enter one letter: ");
try1 = in.next();
}
do // for later
{
}
while(answer!=progress);
}
}
}

New Topic/Question
Reply



MultiQuote







|