Skip to content
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

Sheshtawy #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions lib/deaf_grandma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Copy link
Member

Choose a reason for hiding this comment

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

These three regular expressions could be extracted to constants, since they are the same every time this method is called.

response = ''
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this local variable. Below, you conditionally assign different values to it, but you don't do anything else with response. I'm pretty sure this method will behave the same if you don't have this local variable and just put those three strings in each part of the if/elsif/elsif.

if lower.match(input)
response = 'SPEAK UP SONNY!'
elsif bye.match(input)
response = 'SEE YOU LATER SONNY!'
elsif upper.match(input)
Copy link
Member

Choose a reason for hiding this comment

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

What if the input matches none of these regular expressions? I think that would happen if there is no letter in the input.

response = 'NOT SINCE 1964!'
end
end

private
Expand Down
12 changes: 9 additions & 3 deletions lib/fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/deaf_grandma_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
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(634)).to eq 634
end
end