diff --git a/lib/deaf_grandma.rb b/lib/deaf_grandma.rb index 83ad52a..cb68bb2 100644 --- a/lib/deaf_grandma.rb +++ b/lib/deaf_grandma.rb @@ -19,9 +19,17 @@ def run! def speak(input) - - #Implement your code here <<<<<<<<< - + upper = /[A-Z]+/ + lower = /[A-Z]?[a-z]+/ + bye = /\A(BYE ?){3}\z/ + response = '' + if lower.match(input) + response = 'SPEAK UP SONNY!' + elsif bye.match(input) + response = 'SEE YOU LATER SONNY!' + elsif upper.match(input) + response = 'NOT SINCE 1964!' + end end private diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index 86f9def..0303124 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -1,9 +1,15 @@ class SuperFizzBuzz def run(input) - - #Implement your code here - + if (input % 3 == 0) and (input % 5 == 0) + return "FizzBuzz" + elsif input % 3 == 0 + return "Fizz" + elsif input % 5 == 0 + return "Buzz" + else + return input + end end end diff --git a/spec/deaf_grandma_spec.rb b/spec/deaf_grandma_spec.rb index cf09766..c431df8 100644 --- a/spec/deaf_grandma_spec.rb +++ b/spec/deaf_grandma_spec.rb @@ -9,10 +9,10 @@ end it "says 'NOT SINCE 1964!' when we yell" do - #implement your test here + expect(script.speak("WHEN WAS THE LAST TIME YOU HAD ICE CREAM")).to eq "NOT SINCE 1964!" end - it "EXTRA CREDIT: How would you test yelling BYE?" do - #implement your test here + it "says 'SEE YOU LATER SONNY!' when yell BYE three times exactly " do + expect(script.speak("BYE BYE BYE")).to eq "SEE YOU LATER SONNY!" end end diff --git a/spec/fizzbuzz_spec.rb b/spec/fizzbuzz_spec.rb index cfda46b..0c047ac 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(634)).to eq 634 end end