Skip to content

Instantly share code, notes, and snippets.

@bomatson
Created June 26, 2014 17:41
Show Gist options
  • Save bomatson/da55822b3c80ee9722db to your computer and use it in GitHub Desktop.
Save bomatson/da55822b3c80ee9722db to your computer and use it in GitHub Desktop.
puts "Welcome to Restaurant 720"
#appetizers-------------------------------
apps = ["none", "nachos", "bread sticks", "garlic knots"]
ents = ["none", "burger", "steak", "chicken"]
dess = ["none", "pie", "cake", "ice cream"]
drin = ["none", "water", "soda", "juice"]
#create an empty hash here
order = {'users_order' => [], 'notes_order' => []}
puts # making a new line, puts an empty string
puts "Appetizers:"
apps.each_with_index do |item, index|
puts "#{index}: #{item}"
end
puts "What would you like for your appetizer?"
user_input = gets().chomp().to_i()
sel_app = apps[user_input]
puts "Do you have any notes on how it should be made?"
notes_input_app = gets().chomp()
# down here, you add the selected app and notes to the respective keys
order['users_order'] << sel_app
order['notes_order'] << notes_input_app
#entrees-------------------------------
puts # making a new line, puts an empty string
puts "Entrees:"
ents.each_with_index do |x, i|
puts "#{i}: #{x}"
end
puts "What would you like for your entree?"
ent_input = gets().chomp().to_i()
sel_ent = ents[ent_input]
#puts "You ordered #{sel_app}"
puts "Do you have any notes on how it should be made?"
notes_input_ent = gets().chomp()
order['users_order']<< sel_ent
order['notes_order'] << notes_input_ent
#desserts-------------------------------
puts # making a new line, puts an empty string
puts "Desserts:"
dess.each_with_index do |x, i|
puts "#{i}: #{x}"
end
puts "What would you like for your dessert?"
dess_input = gets().chomp().to_i()
sel_dess = dess[dess_input]
#puts "You ordered #{sel_dess}"
puts "Do you have any notes on how it should be made?"
notes_input_dess = gets().chomp()
order['users_order'] << sel_dess
order['notes_order'] << notes_input_dess
#drinks-------------------------------
puts # making a new line, puts an empty string
puts "Drinks:"
drin.each_with_index do |x, i|
puts "#{i}: #{x}"
end
puts "What would you like for your drink?"
drin_input = gets().chomp().to_i()
sel_drin = drin[drin_input]
#puts "You ordered #{sel_drin}"
puts "Do you have any notes on how it should be made?"
notes_input_drin = gets().chomp()
order['users_order'] << sel_drin
order['notes_order'] << notes_input_drin
#final order-------------------------------
puts
puts "Here is a summary of your order, with your notes provided below."
order['users_order'].each do |item|
puts " * #{item}"
end
order['notes_order'].each do |note|
puts "Notes:
#{note}"
end
# That may seem like an arbitrary change, until you start using functions to do the work for you:
def take_order(order_hash, course)
user_input = gets().chomp().to_i()
selected = course[user_input]
puts "Do you have any notes on how it should be made?"
notes = gets().chomp()
order_hash['users_order'] << selected
order_hash['notes_order'] << notes
end
# Then use the function here:
puts "What would you like for your appetizer?"
take_order(order, app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment