Skip to content

Instantly share code, notes, and snippets.

@dmgarland
Created March 27, 2013 04:10
Show Gist options
  • Save dmgarland/5251569 to your computer and use it in GitHub Desktop.
Save dmgarland/5251569 to your computer and use it in GitHub Desktop.
Here was that work in progress for the strings and cases stuff we did earlier...
print "Hello, what is your name ? > "
first_name = gets.strip.chomp
puts "Hello #{first_name}"
# Do the same thing for the second name
print "Ok, what is your second name ? >"
last_name = gets.strip.chomp
puts "Your full name is : #{first_name} #{last_name}"
# Ask the user for their age, and say that they can't come
# in if they are less than 21 years old...
print "Er... how old are you? "
age = gets.strip.chomp.to_i
unless age < 21
# Give them a choices of drink, and depending on which
# drink they choose, return the % proof in their bloodstream.
print "What's your poison? "
drink = gets.strip.chomp
case drink
when "stella"
percent = 5
when "rioja"
percent = 14
when "whisky"
percent = 40
else
puts "Sorry we're fresh out of that..."
end
puts "Woah, thats #{percent}%..."
else
puts "You're too young to drink..."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment