Skip to content

Instantly share code, notes, and snippets.

@Ebonkuab
Created January 6, 2016 00:55
Show Gist options
  • Save Ebonkuab/d4eb71ba6dffeab052cb to your computer and use it in GitHub Desktop.
Save Ebonkuab/d4eb71ba6dffeab052cb to your computer and use it in GitHub Desktop.
an exercise for checking if the bolean operation is correct for the problem being solved
# must be baller and either furnished or rent cheaper than 2100
def rent?(furnished, rent, baller)
#if baller && furnished || rent < 2100
if baller && (furnished || rent < 2100)
return true
else
return false
end
end
=begin
rescue Exception => e
end
print "is the apartment furnished?"
furnished = gets.chomp
print " How much does it cost to rent the apartment/month"
rent = gets.chomp.to_i
print " is the apartment a baller"
baller = gets.chomp
puts furnished.class
=end
furnished = true
puts furnished
rent = 2100
puts rent
baller = true
puts baller
Would_I_rent =rent?(furnished, rent, baller )
if Would_I_rent == true
puts " I will rent the apartment"
else
puts "No way, I cannot rent this partment"
end
furnished = false
puts furnished
rent = 2100
puts rent
baller = true
puts baller
Would_I_rent =rent?(furnished, rent, baller )
if Would_I_rent == true
puts " I will rent the apartment"
else
puts "No way, I cannot rent this partment"
end
furnished = true
puts furnished
rent = 2100
puts rent
baller = false
puts baller
Would_I_rent =rent?(furnished, rent, baller )
if Would_I_rent == true
puts " I will rent the apartment"
else
puts "No way, I cannot rent this partment"
end
furnished = true
puts furnished
rent = 2300
puts rent
baller = true
puts baller
Would_I_rent =rent?(furnished, rent, baller )
if Would_I_rent == true
puts " I will rent the apartment"
else
puts "No way, I cannot rent this partment"
end
furnished = true
puts furnished
rent = 1900
puts rent
baller = false
puts baller
Would_I_rent =rent?(furnished, rent, baller )
if Would_I_rent == true
puts " I will rent the apartment"
else
puts "No way, I cannot rent this partment"
end
furnished = false
puts furnished
rent = 1900
puts rent
baller = true
puts baller
Would_I_rent =rent?(furnished, rent, baller )
if Would_I_rent == true
puts " I will rent the apartment"
else
puts "No way, I cannot rent this partment"
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.
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment