Created
August 5, 2011 04:59
-
-
Save benfb/1126940 to your computer and use it in GitHub Desktop.
A simple restaurant robot
This file contains 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
# Restaurbot | |
$done = false | |
orders = [ | |
'pizza', 'macaroni' | |
] | |
puts 'Hello. What is your name?' | |
$name = gets.chomp.capitalize | |
puts 'Hello, ' + $name + '.' | |
if $name == 'Ben' | |
puts 'You\'re awesome!' | |
else | |
puts 'You\'re stupid!' | |
end | |
until $done == true | |
puts 'What would you like to order, ' + $name + '?' | |
puts 'There are currently ' + orders.length.to_s + ' available orders.' | |
puts 'Type "add" to add an order, "order" to display the orders, or "del" to delete an order.' | |
$choice = gets.chomp.downcase | |
if $choice == 'add' | |
puts 'Type the name of the order you want to add:' | |
$order_add = gets.chomp.downcase | |
orders.push($order_add) | |
puts 'Order ' + orders.last + ' has been added!' | |
end | |
if $choice == 'del' | |
puts 'Type the name of the order you want to delete:' | |
$order_del = gets.chomp.downcase | |
orders.delete($order_del) | |
puts 'Order ' + $order_del + ' has been deleted!' | |
puts 'These are the current orders:' + orders.to_s + '' | |
end | |
if $choice == 'order' | |
puts 'These are the current orders:' + orders.to_s + '' | |
puts 'Type the name of the order you want to order:' | |
$order = gets.chomp.downcase | |
if orders.include?($order) | |
puts 'WEIRDO' | |
else | |
puts '' + $order + ' is a really weird food!' | |
$done = true | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment