diff --git a/exercises/bob/README.md b/exercises/bob/README.md index 54cc1d41b..1755559ad 100644 --- a/exercises/bob/README.md +++ b/exercises/bob/README.md @@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question. He answers 'Whoa, chill out!' if you yell at him. +He answers 'Calm down, I know what I'm doing!' if you yell a question at him. + He says 'Fine. Be that way!' if you address him without actually saying anything. diff --git a/exercises/bob/src/example.clj b/exercises/bob/src/example.clj index 7dffb9543..fd4d2d4fb 100644 --- a/exercises/bob/src/example.clj +++ b/exercises/bob/src/example.clj @@ -10,8 +10,12 @@ (defn- shouting? [msg] (and (= msg (str/upper-case msg)) (has-letter? msg))) +(defn- forceful-question? [msg] + (and (shouting? msg) (question? msg))) + (defn response-for [input] (cond + (forceful-question? input) "Calm down, I know what I'm doing!" (silence? input) "Fine. Be that way!" (shouting? input) "Whoa, chill out!" (question? input) "Sure." diff --git a/exercises/bob/test/bob_test.clj b/exercises/bob/test/bob_test.clj index 317b68e3b..2e774ebbf 100644 --- a/exercises/bob/test/bob_test.clj +++ b/exercises/bob/test/bob_test.clj @@ -20,7 +20,7 @@ (bob/response-for "It's OK if you don't want to go to the DMV.")))) (deftest responds-to-forceful-questions - (is (= "Whoa, chill out!" + (is (= "Calm down, I know what I'm doing!" (bob/response-for "WHAT THE HELL WERE YOU THINKING?")))) (deftest responds-to-shouting-with-special-characters