diff --git a/lib/deaf_grandma.rb b/lib/deaf_grandma.rb index 83ad52a..b16a737 100644 --- a/lib/deaf_grandma.rb +++ b/lib/deaf_grandma.rb @@ -4,23 +4,37 @@ class DeafGrandma - def initialize - @bye_counter = 0 - end + def initialize() + @bye_counter = 0 + end + def run! print_welcome loop do user_input = get_user_input p speak(user_input) + if @bye_counter == 3 + exit! + end end end - - + def speak(input) - #Implement your code here <<<<<<<<< + if input == "Hi Grandma" + return "SPEAK UP SONNY!" + end + if input == "YELL" + return "NOT SINCE 1964!" + end + if input == "BYE" + @bye_counter += 1 + if @bye_counter == 3 + return "SEE YOU LATER SONNY!" + end + end end diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index 86f9def..864cab4 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -2,8 +2,16 @@ class SuperFizzBuzz def run(input) - #Implement your code here - + if input % 3 == 0 + if input % 5 == 0 + return "FizzBuzz" + end + return "Fizz" + end + if input % 5 == 0 + return "Buzz" + end + return input end end diff --git a/spec/deaf_grandma_spec.rb b/spec/deaf_grandma_spec.rb index cf09766..6970039 100644 --- a/spec/deaf_grandma_spec.rb +++ b/spec/deaf_grandma_spec.rb @@ -2,6 +2,7 @@ require 'deaf_grandma' describe 'DeafGrandma' do + let(:script) { DeafGrandma.new } it "says 'SPEAK UP SONNY!' when we speak regularly" do @@ -9,10 +10,18 @@ end it "says 'NOT SINCE 1964!' when we yell" do - #implement your test here + expect(script.speak("YELL")).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..71da170 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(17)).to eq 17 end end