Skip to content

Issue #214: Update bob for ambiguous case #223

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

Merged
merged 1 commit into from
May 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions exercises/bob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions exercises/bob/src/example.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion exercises/bob/test/bob_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down