Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(course question) Hangman final test #237

Open
p3p3fr0g opened this issue Oct 17, 2024 · 1 comment
Open

(course question) Hangman final test #237

p3p3fr0g opened this issue Oct 17, 2024 · 1 comment

Comments

@p3p3fr0g
Copy link

p3p3fr0g commented Oct 17, 2024

`fun playGame(secret: String, maxAttemptsCount: Int): Unit {
    var currentUserWord = getHiddenSecret(wordLength)
    var complete = false
    var guess: Char
    var attempts = 0
    while (true) {
        if (isLost(complete, attempts, maxAttemptsCount)) {
            println("Sorry, you lost! My word is $secret")
            break
        }
        if (isWon(complete, attempts, maxAttemptsCount)) {
            println("Congratulations! You guessed it!")
            break
        }
        guess = safeUserInput()
        currentUserWord = getRoundResults(secret, guess, currentUserWord)
        complete = isComplete(secret, currentUserWord)
        attempts++
    }
}`

When I run my program, it exits correctly after 9 failed guesses or solving the puzzle. However, when running the tests (that appear to test it with random inputs?) it gives me this error

Try to run the main function with the user input: V A W G T C U R D J L P Z Q F O K I X B Y H N M E S , the function must process the input and exit, but the current version of the function waits more user inputs, it must be fixed.

Now from what I gather, the program should be terminating after 8 inputs not 9, so if i change the initialization from var attempts = 0 to var attempts = 1, and run the program, it terminates after not getting the word in 8 tries, but now gives me an additional failed test ("You are asking the user to enter data fewer times than required in the task!") and still gives me failure of the not terminating test?

Not understanding why when I run the program in the terminal it successfully terminates but doesn't in the course's test, is this an error in the program or the test?, and also not understanding why if max attempts is supposed to be 8, the other test passes on 9 tries but fails on 8?

@p3p3fr0g
Copy link
Author

p3p3fr0g commented Oct 17, 2024

also why when i selected my code to be code in the editor did it not preserve my line breaks? apparently you have to select code twice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant