Skip to content

Instantly share code, notes, and snippets.

@clark-teeple
Forked from davidvandusen/renter.rb
Last active August 29, 2015 14:28
Show Gist options
  • Save clark-teeple/a90b25ee5e06ef26d0d7 to your computer and use it in GitHub Desktop.
Save clark-teeple/a90b25ee5e06ef26d0d7 to your computer and use it in GitHub Desktop.
# must be baller and either furnished or rent cheaper than 2100
def rent?(furnished, rent, baller)
if baller && furnished || rent < 2100
return true
else
return false
end
end
###
# Add your "test" ("driver") code below in order to "test drive" (run) your method above...
# The test code will call the method with different permutations of options and output the result each time.
# This way, you will be able to run the renter.rb file from the CLI and look at the output of your "tests" to validate if the method works.
# Without the test code, it will be hard for you to know if this method is working as it should or not.
###
puts "should all be true"
puts rent?(true,2100,true)
puts rent?(true, 2099, true)
puts rent?(true, 2101, true)
puts rent?(false, 2099, true)
puts "should be false"
puts rent?(false, 2101, true)
puts rent?(false, 2100, true)
puts rent?(true, 2100, false)
puts rent?(true, 2099, false)
puts rent?(true, 2101, false)
puts rent?(false, 2100, false)
puts rent?(false, 2099, false)
puts rent?(false, 2101, false)
puts " "
puts "clearly not working"
def rent_2(furnished, rent, baller)
return baller && furnished || baller && rent < 2100
end
puts "should all be true"
puts rent_2(true,2100,true)
puts rent_2(true, 2099, true)
puts rent_2(true, 2101, true)
puts rent_2(false, 2099, true)
puts "should be false"
puts rent_2(false, 2101, true)
puts rent_2(false, 2100, true)
puts rent_2(true, 2100, false)
puts rent_2(true, 2099, false)
puts rent_2(true, 2101, false)
puts rent_2(false, 2100, false)
puts rent_2(false, 2099, false)
puts rent_2(false, 2101, false)
puts "booyah"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment