diff --git a/lib/deaf_grandma.rb b/lib/deaf_grandma.rb index 83ad52a..b1e94ac 100644 --- a/lib/deaf_grandma.rb +++ b/lib/deaf_grandma.rb @@ -14,14 +14,17 @@ def run! loop do user_input = get_user_input p speak(user_input) + exit(0) if @bye_counter == 3 end end def speak(input) - - #Implement your code here <<<<<<<<< - + @bye_counter += 1 if input == "BYE" + result = "SPEAK UP SONNY!" if input != input.upcase + result = "NOT SINCE 1964!" if input == input.upcase + result = "SEE YOU LATER SONNY!" if @bye_counter == 3 + result end private diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index 86f9def..55169a3 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -1,13 +1,18 @@ class SuperFizzBuzz def run(input) + result = "" + result << "Fizz" if input % 3 == 0 + result << "Buzz" if input % 5 == 0 + result = input if result.empty? - #Implement your code here - + result 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. + +# buzzer = SuperFizzBuzz.new +# buzzer.run(5) \ No newline at end of file diff --git a/spec/deaf_grandma_spec.rb b/spec/deaf_grandma_spec.rb index cf09766..5cff612 100644 --- a/spec/deaf_grandma_spec.rb +++ b/spec/deaf_grandma_spec.rb @@ -9,10 +9,12 @@ end it "says 'NOT SINCE 1964!' when we yell" do - #implement your test here + expect(script.speak("HI GRANDMA")).to eq "NOT SINCE 1964!" end it "EXTRA CREDIT: How would you test yelling BYE?" do - #implement your test here + script.speak("BYE") + script.speak("BYE") + expect(script.speak("BYE")).to eq "SEE YOU LATER SONNY!" end end diff --git a/spec/fizzbuzz_spec.rb b/spec/fizzbuzz_spec.rb index cfda46b..0a2affd 100644 --- a/spec/fizzbuzz_spec.rb +++ b/spec/fizzbuzz_spec.rb @@ -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(2)).to eq 2 end end