Skip to content
Open

done #99

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
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
source 'https://rubygems.org'
ruby '2.0.0'

gem 'rspec', '~> 3.0.0.beta2'
22 changes: 19 additions & 3 deletions lib/deaf_grandma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,30 @@ def run!
loop do
user_input = get_user_input
p speak(user_input)
if @bye_counter == 3 then
exit
end
end
end


def speak(input)

#Implement your code here <<<<<<<<<

if input == input.upcase then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then is optional in Ruby and typically unused. (It might be true that it is always unused.)

if input == "BYE" then
@bye_counter = @bye_counter + 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bye_counter += 1 is the shorthand way of expressing this.

if @bye_counter == 3 then
"SEE YOU LATER SONNY!"
else
""
end
else
@bye_counter = 0
"NOT SINCE 1964!"
end
else
@bye_counter = 0
"SPEAK UP SONNY!"
end
end

private
Expand Down
13 changes: 10 additions & 3 deletions lib/fizzbuzz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ class SuperFizzBuzz

def run(input)

#Implement your code here

if input % 3 == 0 && input % 5 == 0 then
"FizzBuzz"
elsif input % 3 == 0 then
"Fizz"
elsif input % 5 == 0 then
"Buzz"
else
input
end
end

end

#You don't necessarily need to execute this script to complete this challenge, but how would you "run" this method (pun intended) so that it printed a value to the terminal?
#
#HINT: it's an instance method.
#p SuperFizzBuzz.new.run(3)
6 changes: 4 additions & 2 deletions spec/deaf_grandma_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
end

it "says 'NOT SINCE 1964!' when we yell" do
#implement your test here
expect(script.speak("HI")).to eq "NOT SINCE 1964!"
end

it "EXTRA CREDIT: How would you test yelling BYE?" do
#implement your test here
expect(script.speak("BYE")).to eq ""
expect(script.speak("BYE")).to eq ""
expect(script.speak("BYE")).to eq "SEE YOU LATER SONNY!"
end
end
6 changes: 3 additions & 3 deletions spec/fizzbuzz_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
end

it "returns 'Buzz' when my input is divisible by 5" do
#implement your test here
expect(script.run(5)).to eq "Buzz"
end

it "returns 'FizzBuzz' when input is divisible by 3 & 5" do
#implement your test here
expect(script.run(15)).to eq "FizzBuzz"
end

it "returns the input number when input isn't divisible by 3, 5, or both" do
#implement your test here
expect(script.run(4)).to eq 4
end
end