Java Hangman程序完成了,但我仍然有一些问题(我不确定我用来检查信件的数组)

Java Hangman程序完成了,但我仍然有一些问题(我不确定我用来检查信件的数组),java,Java,这里至少需要一个分号: /* prompt user for a word */ c.print("Enter a letter: "); guessletter = c.readLine(); // start guessing! // keep the user guessing (do while loop) until user types in "!" or the game screen is all filled with letters // add one to numbe

这里至少需要一个分号:

  /* prompt user for a word */
c.print("Enter a letter: ");
guessletter = c.readLine();
// start guessing!
// keep the user guessing (do while loop) until user types in "!" or the game screen is all filled with letters
// add one to numberofguesses to as a counter for the guesses the user makes
// A string lu(Letters Used) is created to hol the letters the user has already guessed.
String lu;
Boolean canPlay = true; 
    do
    {
    c.println ("(TYPE (!) TO GUESS THE WHOLE MYSTERY WORD!)");
    c.println (screen);
    c.println ("Please guess a letter:  ");
    guessletter = c.readLine ();
    numberofguesses = numberofguesses + 1;
// change user's guessed letter to upper case.
    guessletter = guessletter.toUpperCase ();
// make an index for which space the guessed letter is in the secret word.
    int indexof = SECRET_WORD.indexOf (guessletter);
// if the guessed letter DOES appear in the secret word
// then replace the guessed letter on the corresponding dash on the newscreen
// the dashes that is in front of the corresponding dash and behind it is not changed to the current newscreen.
// the replace the information of the old screen with the new screen.
    if (indexof > -1)
    {
      newscreen = (screen.substring (0,indexof) + guessletter + screen.substring (indexof+1));
      screen = newscreen; 
    }
    }while (GUESS_FULL_WORD.compareTo (guessletter)!= 0 && SECRET_WORD.compareTo (screen) !=0);

// if the screen equals the secret word (the dashes are all replaced with letters)
// then indicate that the user have won.
// also include the secret word and the number of guesses the used have made.
    if (screen.equals (SECRET_WORD))
    {
      c.println ("WOW!! YOU WON!! (:");
      c.println ("The scecret word was..." +SECRET_WORD);
      c.println ("You've guessed the total of " +numberofguesses+ " times");
    }
// if the user enters "!" then
    if (guessletter.equals (GUESS_FULL_WORD))
    {
    c.println (screen);
// allow the user to guess the whole word.
    c.println ("What is the secret word?  ");
    guessword = c.readLine ();
// change the user's guess into upper case
    guessword = guessword.toUpperCase ();

   if (numberofguesses==6)
{
canPlay = false;
Lose();
}
else
/*
* Put man here
          --
          o |
         /|\|
         / \|
         _____
*/
        String man[] = new String[7]
        man[0] = " --\n   |\n   |\n   |\n_____\n";
        man[1] = " --\n o |\n   |\n   |\n_____\n";
        man[2] = " --\n o |\n/  |\n   |\n_____\n";
        man[3] = " --\n o |\n/| |\n   |\n_____\n";
        man[4] = " --\n o |\n/|\\|\n   |\n_____\n";
        man[5] = " --\n o |\n/|\\|\n/  |\n_____\n";
        man[6] = " --\n o |\n/|\\|\n/ \\|\n_____\n";
char g1[] = guess.toCharArray();
        char w2[] = word.toCharArray();
        c.println(man[0]);
        for(int x=0;x<g1.length;x++)
        {
          c.print(g1[x]);
        }
        c.println();

// inside the if-statement...
// if the user's guess (full word) match with the secret word then
// indicate that the user have won.
// also include the secret word and also the number of guesses the user have made.
    if (guessword.compareTo (SECRET_WORD) ==0)
    {
      c.println ("WOW!! YOU'VE GUESSED IT!! (:");
      c.println ("The scecret word was..." +SECRET_WORD);
      c.println ("You've guessed the total of " +numberofguesses+ " times");
    }
// if the user's guess (full word) does not match with the secret word then
// indicate that the user have lost.
// also include the secret word and also the number of guesses the user have made
    else
    {
      c.println ("OOPS...! YOU LOSE!! ):");
      c.println ("The scecret word was..." +SECRET_WORD);
      c.println ("You've guessed the total of " +numberofguesses+ " times");
    }
    }
将此更改为:

String man[] = new String[7]
这就是第166行的问题所在。第203行上的问题可能是通过以下方式解决的,也可能是由于代码中缺少右大括号}或只是不匹配的大括号。

String man[] = new String[7];
需要一个;最后

还有前面几行的else语句,后面没有大括号


失去了什么;?看起来像是一个函数调用,但您没有相应的函数。

您应该在每次更改代码时进行编译并修复这些错误,这样您就不必在开始调试之前处理十几个语法错误

        String man[] = new String[7]
是缺少一个

前面的else缺少一个{,文件末尾缺少几个}


顺便说一句,正确缩进代码这对查找不匹配的大括号有很大帮助

我喜欢它在错误中的表述,但他仍然需要问我们。
        String man[] = new String[7]
String man[] = new String[7]