Created
June 24, 2014 23:59
-
-
Save bomatson/aa8937fd5ac446dccfd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apps =[ "nachos","guacamole","bloomin onion","bread sticks","garlic knots", "No thanks"] | |
ents =["hamburger","lobster","chicken","No thanks"] | |
desserts= ["coffee","cake","ice cream","No thanks"] | |
drinks= ["Coke", "Water", "Beer", "Milkshake","No thanks"] | |
bill=[] | |
# It seems like you list the items several times in your code: | |
drinks.each_with_index do |item,index| | |
puts "#{index}: #{item}" | |
end | |
# Why not create a function that does it for you: | |
def list_items(course) | |
course.each_with_index do |item, index| | |
puts "#{index}: #{item}" | |
end | |
end | |
# then you can call: | |
list_items(drinks) | |
# and you'll get the same output. See below: | |
puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" | |
puts"Welcome to R720" | |
puts | |
puts "Would you like something to drink?" | |
# USED HERE | |
list_items(drinks) | |
user_input=gets().chomp().to_i() | |
selected_drink= drinks[user_input] | |
if selected_drink=="No thanks" | |
puts "Thats a shame..." | |
else | |
puts "#{selected_drink} is my favorite! How do you want it prepared?" | |
user_input2=gets().chomp().upcase | |
puts "#{user_input2}" "!!!!!!!!!!!" | |
bill << selected_drink | |
end | |
puts "_______________________________________" | |
puts "would you like an appetizer?" | |
# HERE | |
list_items(apps) | |
user_input = gets().chomp().to_i() | |
selected_appetizer = apps[user_input] | |
if selected_appetizer=="No thanks" | |
puts "Well thats a mistake!" | |
else | |
puts " You ordered #{selected_appetizer} ! How do you want it prepared?" | |
user_input2=gets().chomp().upcase | |
puts "#{user_input2}" "!!!!!!!!!!!" | |
bill << selected_appetizer | |
end | |
puts | |
puts "Entrees" | |
puts "___________________________________" | |
# HERE | |
list_items(ents) | |
user_input = gets().chomp().to_i() | |
selected_entree = ents[user_input] | |
if selected_entree== "No thanks" | |
puts "Good thinking with that belly!" | |
else | |
puts "You ordered #{selected_entree}. How would you like it prepared?" | |
user_input2=gets().chomp().upcase | |
puts "#{user_input2}" "!!!!!!!!!!!" | |
"What would you like for dessert?" | |
bill << selected_entree | |
puts "Desserts" | |
# AND HERE | |
list_items(desserts) | |
puts | |
user_input = gets().chomp().to_i() | |
selected_dessert = desserts[user_input] | |
if selected_dessert== "No thanks" | |
puts "Thats a shame..." | |
else | |
puts "You ordered #{selected_dessert}. How would you like it prepared?" | |
user_input2=gets().chomp().upcase | |
puts "#{user_input2}" "!!!!!!!!!!!" | |
bill << selected_dessert | |
end | |
puts"_____________________________________" | |
puts"Your bill" | |
bill.each_with_index do |item,index| | |
puts "* #{item}:" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment