Sha256: ab5dee0a060bea7cf094fab4c054383c3828ca0cad7d47a35cd9a1d4ed945d8c

Contents?: true

Size: 648 Bytes

Versions: 270

Compression:

Stored size: 648 Bytes

Contents

/**
 * Bob is a lackadasical teenager.
 */
object Bob {
    fun hey(input: String): String {
        return when {
            isSilence(input) -> "Fine. Be that way!"
            isShout(input) -> "Whoa, chill out!"
            isQuestion(input) -> "Sure."
            else -> "Whatever."
        }
    }

    private fun isSilence(input: String) = input.isBlank()
    private fun isQuestion(input: String) = input.endsWith("?")
    private fun isShout(input: String): Boolean {
        val isOnlyUppercase = input == input.toUpperCase()
        val hasLetter = input.contains(Regex("[A-Z]"))

        return hasLetter && isOnlyUppercase
    }

}

Version data entries

270 entries across 270 versions & 1 rubygems

Version Path
trackler-2.2.1.52 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.51 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.50 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.49 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.48 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.47 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.46 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.45 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.44 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.43 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.42 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.41 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.40 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.39 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.38 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.37 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.36 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.35 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.34 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt
trackler-2.2.1.33 tracks/kotlin/exercises/bob/.meta/src/reference/kotlin/Bob.kt