Skip to content

Commit 13aab88

Browse files
authored
Merge pull request #223 from haus/update_bob_exercise
Issue #214: Update bob for ambiguous case
2 parents d6fbe98 + 1606fd3 commit 13aab88

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

exercises/bob/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question.
66

77
He answers 'Whoa, chill out!' if you yell at him.
88

9+
He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
10+
911
He says 'Fine. Be that way!' if you address him without actually saying
1012
anything.
1113

exercises/bob/src/example.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
(defn- shouting? [msg] (and (= msg (str/upper-case msg))
1111
(has-letter? msg)))
1212

13+
(defn- forceful-question? [msg]
14+
(and (shouting? msg) (question? msg)))
15+
1316
(defn response-for [input]
1417
(cond
18+
(forceful-question? input) "Calm down, I know what I'm doing!"
1519
(silence? input) "Fine. Be that way!"
1620
(shouting? input) "Whoa, chill out!"
1721
(question? input) "Sure."

exercises/bob/test/bob_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
(bob/response-for "It's OK if you don't want to go to the DMV."))))
2121

2222
(deftest responds-to-forceful-questions
23-
(is (= "Whoa, chill out!"
23+
(is (= "Calm down, I know what I'm doing!"
2424
(bob/response-for "WHAT THE HELL WERE YOU THINKING?"))))
2525

2626
(deftest responds-to-shouting-with-special-characters

0 commit comments

Comments
 (0)