From d0eacd9dfa8b480317361577e5109efccf76887c Mon Sep 17 00:00:00 2001 From: add2point71dots Date: Thu, 9 Feb 2017 09:10:46 -0800 Subject: [PATCH 1/4] Create random_menu.rb --- random_menu.rb | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 random_menu.rb diff --git a/random_menu.rb b/random_menu.rb new file mode 100644 index 0000000..20c230d --- /dev/null +++ b/random_menu.rb @@ -0,0 +1,87 @@ +adjectives = [] +cooking_things = [] +foods = [] + +#gets some number of inputs from user and fills specified array +def fill_arrays(description, array, number) + puts + number.times do |num| + get_input = true + while get_input do + #asks for and stores user inputs + print "Give me #{description} ##{num+1}: " + new_item = gets.chomp + + if !array.include?(new_item) #adds input to array if unique + array << new_item + get_input = false + else + puts "\nYou already gave me that one!" + end + end + end +end + +#gets a number from the user greater than 0 and >= the specified max +def get_user_number(max, message) + puts + user_num = -1 + until (user_num > 0) && (user_num <= max) do + print message + user_num = gets.chomp.to_i + if user_num <= 0 + puts "\nIt has to be at least one." + end + if user_num > max + puts "\nThat's too many!" + end + end + return user_num +end + +#asks if user wants to create their own menu +create = nil +until create == "y" || create == "n" do + print "\nDo you want to create your own random menu words? (y/n) " + create = gets.chomp +end + +if create == "n" #creates menu words if user decies not to + adjectives = ["special", "gooey", "awesome", "hot", "saucy", "spicy", "salty", "orange", "sharp", "beautiful"] + cooking_things = ["chopped", "boiled", "deep-fried", "squished", "melted", "mashed", "raw", "toasted", "caramelized", "juiced"] + foods = ["peas", "bread", "cake", "peanuts", "berries", "soup", "pasta", "vegetables", "cabbage", "tacos"] + + +else #gets menu words from user + + #gets number of words the user wants to supply between 1 and 10 + num_words = get_user_number(10, "How many words do you want per category? ") + + #gets user inputs for 3 categories and stores them + fill_arrays("Silly Adjective", adjectives, num_words) + fill_arrays("Cooking Adjective", cooking_things, num_words) + fill_arrays("Food", foods, num_words) + +end + +#gets number of menu items to display from user +num_items = get_user_number(adjectives.length, "How many random menu items would you like to see? ") + +puts "\nMENU" + +#randomizes menu items and displays with no duplicates +num_items.times do |num| + adjective = adjectives.sample #chooses random word + adjectives.delete(adjective) #deletes word from array + + cooking_thing = cooking_things.sample + cooking_things.delete(cooking_thing) + + food = foods.sample + foods.delete(food) + + puts + puts "#{num + 1}. #{adjective} #{cooking_thing} #{food}" +end + +puts From 03ad133194c832b2aedd27396f5f3d480e37ccbe Mon Sep 17 00:00:00 2001 From: add2point71dots Date: Sun, 29 Oct 2017 17:17:42 -0700 Subject: [PATCH 2/4] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 737d411..a437d5a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # Random Menu Generator +An assignment completed during my time at Ada Developers Academy. + +Instructions below: + Create a program that runs from the Terminal that will create a random menu based on several items that you determine. ## Baseline From 207bf0ff8493d9ecfbb8d96ac6488a8bcc1f6f06 Mon Sep 17 00:00:00 2001 From: add2point71dots Date: Sun, 29 Oct 2017 17:18:40 -0700 Subject: [PATCH 3/4] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a437d5a..a577493 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Random Menu Generator An assignment completed during my time at Ada Developers Academy. -Instructions below: +Original Instructions +--- Create a program that runs from the Terminal that will create a random menu based on several items that you determine. From 3697da232f9a354dda6de20c1fd3cebef9d85e53 Mon Sep 17 00:00:00 2001 From: add2point71dots Date: Sun, 29 Oct 2017 17:19:09 -0700 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a577493..27850e9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Random Menu Generator An assignment completed during my time at Ada Developers Academy. -Original Instructions +Assignment Guidelines: --- Create a program that runs from the Terminal that will create a random menu based on several items that you determine.