调用Hangman的方法

时间:2016-11-01 18:40:54

标签: java

我让所有方法都正常工作,但我对如何打印剩余猜测的数量感到困惑,并在我的main方法中打印Hangman。我需要通过调用{ "id": 2, "description": "A description", "containedObject": {} } 打印当前的hangMan,但不知道如何在没有猜测计数器的情况下调用它

 {
        "id": 2,
        "description": "A description",
        "containedObject": null
    }

1 个答案:

答案 0 :(得分:0)

人们不打算在这个论坛上为你写作,你通常需要尝试更多,只是说“我被卡住了”。话虽如此,这是一个粗略的大纲,让你超越这一点:

    public static void main(String[] args)
    {
        System.out.println("Welcome to HangMan Player 1, Please enter a word. Player 2, Please close your eyes: ");
        Scanner stdin = new Scanner(System.in);

        String secretWord = stdin.next();

        int guessesLeft = /* Number of guesses at the start */;
        String partialWord = createPartialWord(secretWord);

        while (/* You have guesses remaining */)
        {
            for (int x = 1; x <= 100; x++)
            {
                System.out.println(" ");
            }

            System.out.println("Clearing Screen");

            System.out.println("The current partial word is: ");
            System.out.println(partialWord);
            System.out.println("The current hangman picture is: ");

            printHangman(guessesLeft);

            // TODO: Obtain the next letter from the user
            // TODO: Update the partial word with the letter
            // TODO: Make it such that you have one less guess remaining
        }
    }

另外,我很确定createPartialWord不应该在其中包含print语句。