From c6deb78e9b91ced414b7cc53f0fd4d48f179a336 Mon Sep 17 00:00:00 2001 From: pancake-batfish Date: Thu, 9 Feb 2017 09:10:31 -0800 Subject: [PATCH] Create random_menu.rb --- random_menu.rb | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 random_menu.rb diff --git a/random_menu.rb b/random_menu.rb new file mode 100644 index 0000000..d3beff2 --- /dev/null +++ b/random_menu.rb @@ -0,0 +1,54 @@ +# Bo made me put this in +puts " # # ##### + ## ## ###### # # # # # # ###### # # ###### ##### ## ##### #### ##### + # # # # # ## # # # # # ## # # # # # # # # # # # + # # # ##### # # # # # # #### ##### # # # ##### # # # # # # # # # + # # # # # # # # # # # # # # # ##### ###### # # # ##### + # # # # ## # # # # # # ## # # # # # # # # # # + # # ###### # # #### ##### ###### # # ###### # # # # # #### # # + +" + +word1 = [] +word2 = [] +word3 = [] +words = [word1, word2, word3] + +# set number of items +puts "How many possibilities would you like to have for each menu term?" +options = gets.chomp.to_i + +# accept user input for the word arrays +3.times do |n| + puts "For the next term:" + options.times do + if n < 2 + print "Enter an adjective: " + else + print "Enter a food item: " + end + + word = gets.chomp + words[n] << word + end +end + +# request user input for number of menu items +while true + puts "How many items would you like on your menu? (maximum #{options})" + items = gets.chomp.to_i + if (items <= options) && (items > 0) + break + else + puts "Please select #{options} or fewer menu items." + end +end + +# generate menu items +items.times do |n| + first_word = word1.delete_at(rand(word1.length)) + second_word = word2.delete_at(rand(word2.length)) + third_word = word3.delete_at(rand(word3.length)) + + puts "#{n+1}. #{first_word} #{second_word} #{third_word}" +end