jetbrains-academy / kotlin-onboarding-introduction

The introduction to the Kotlin Onboarding course
MIT License
9 stars 2 forks source link

Fix tests in WarmUp #145

Closed nbirillo closed 11 months ago

nbirillo commented 1 year ago

The current implementation works with

fun safeUserInput(wordLength: Int, alphabet: String): String {
    println("Please input your guess. It should be of length $wordLength, and each symbol should be from the alphabet: $alphabet.")
    val guess: String = safeReadLine()
    isCorrectInput(guess, wordLength, alphabet)
    return guess
}

fun isCorrectInput(userInput: String, wordLength: Int, alphabet: String): Boolean {
    var isCorr = true
    if (userInput.length != wordLength) {
        println("The length of your guess should be $wordLength characters! Try again!")
        isCorr = false
    }
    var flag: Boolean = true
    for (i in userInput) {
        if (i !in alphabet) {
            flag = false
        }
    }
    if (!flag) {
        println("All symbols in your guess should be the $alphabet alphabet characters! Try again!")
        isCorr = false
    }
    return isCorr
}

But the initial idea was to ask user about the correct input while the correct input is not passed

nbirillo commented 11 months ago

Fixed in the course update