From 37c3b55645250425c38a111a855e69d17b56658c Mon Sep 17 00:00:00 2001 From: Brittany Jones Date: Mon, 5 Feb 2018 15:23:11 -0800 Subject: [PATCH 1/3] Starting on day 1 homework --- Random-Menu.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Random-Menu.rb diff --git a/Random-Menu.rb b/Random-Menu.rb new file mode 100644 index 0000000..b739ee2 --- /dev/null +++ b/Random-Menu.rb @@ -0,0 +1,4 @@ +puts "Here is a list of our wonderful menu items." +fd_adj = [ "Spicy Hot" , "Cold" , "Bland" , "Exciting" , "Extreme" , "Deadly" , "Lovely" , "Chilled" , "Boiling"] +fd_style = [ "fried" , "baked" , "seared" , "steamed" , "stinky" , "broiled" , "roasted" , "grilled" , "sauted" , "frozen"] +fd_name = ["ice cream" , "soup" , "chicken" , "crab" , "beef" , "cabbage" , "potato" , "carrots" , "salad" , "lobster"] From 126d9517d7693cb0b75531690e32b26be64ff850 Mon Sep 17 00:00:00 2001 From: Brittany Jones Date: Mon, 5 Feb 2018 20:32:50 -0800 Subject: [PATCH 2/3] Created first draft of Random Menu Generator. --- Random-Menu.rb | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Random-Menu.rb b/Random-Menu.rb index b739ee2..2a0e1f9 100644 --- a/Random-Menu.rb +++ b/Random-Menu.rb @@ -1,4 +1,34 @@ -puts "Here is a list of our wonderful menu items." -fd_adj = [ "Spicy Hot" , "Cold" , "Bland" , "Exciting" , "Extreme" , "Deadly" , "Lovely" , "Chilled" , "Boiling"] -fd_style = [ "fried" , "baked" , "seared" , "steamed" , "stinky" , "broiled" , "roasted" , "grilled" , "sauted" , "frozen"] +# Ada Random Menu generator Day 1 Homework +# Brittany Jones +# Last edited 2/5/18 + +puts "Here is a list of the menu items." +# Come up with the three arrays of ten items each. +# Array of Adjectives to describe the plate +fd_adj = [ "Spicy Hot" , "Cold" , "Bland" , "Exciting" , "Extreme" , "Deadly" , "Lovely" , "Chilled" , "Boiling" , "Juicy"] +# Array of cooking styles +fd_style = [ "fried" , "baked" , "seared" , "steamed" , "stinky" , "broiled" , "roasted" , "grilled" , "sauteed" , "frozen"] +# Array of food name fd_name = ["ice cream" , "soup" , "chicken" , "crab" , "beef" , "cabbage" , "potato" , "carrots" , "salad" , "lobster"] + +# Create menu array to store menu items ramdomized +menu = [] +10.times do |x| +# Will delete from array once it has been accessed, so there are no duplicated menu items. +menu << "#{fd_adj.delete(fd_adj.sample)} #{fd_style.delete(fd_style.sample)} #{fd_name.delete(fd_name.sample)}" +end +# will print out each index +1, so starting with 1 instead of 0, and then:, and then each menu item x. +# prints the return value of each with indeces 1-10 +menu.each_with_index do |x, i| +# This will print out a list starting at 1, and going until 10, as well as the randomly generated food name. +puts "#{i+1}: #{x}" +end + + +puts "\nNot seeing anything you like?" +like = gets.chomp.upcase.to_s +if like == "NO" + puts "How do you like your food cooked?" + cooked = gets.chomp.to_s + fd_style << cooked +end From 96059ca3f51dbe56fd5a1685e0b6c4c7a28478fd Mon Sep 17 00:00:00 2001 From: Brittany Jones Date: Mon, 5 Feb 2018 23:01:38 -0800 Subject: [PATCH 3/3] Changed some code to allow for user to chose how many items they would like to see. --- Random-Menu.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Random-Menu.rb b/Random-Menu.rb index 2a0e1f9..dea5e20 100644 --- a/Random-Menu.rb +++ b/Random-Menu.rb @@ -1,19 +1,28 @@ # Ada Random Menu generator Day 1 Homework # Brittany Jones # Last edited 2/5/18 +puts "How many menu items would you like to view?" +menu_items = gets.chomp.to_i +if menu_items < 11 && menu_items > 0 + puts "Here are #{menu_items} items from our menu:" +elsif menu_items > 10 +puts "We only have 10 menu items. Please enter 1 - 10." +menu_items = gets.chomp.to_i +puts "Here are #{menu_items} items from our menu:" +end + -puts "Here is a list of the menu items." # Come up with the three arrays of ten items each. # Array of Adjectives to describe the plate -fd_adj = [ "Spicy Hot" , "Cold" , "Bland" , "Exciting" , "Extreme" , "Deadly" , "Lovely" , "Chilled" , "Boiling" , "Juicy"] +fd_adj = [ "Spicy hot" , "Cold" , "Bland" , "Exciting" , "Extreme" , "Deadly" , "Lovely" , "Chilled" , "Boiling" , "Juicy"] # Array of cooking styles fd_style = [ "fried" , "baked" , "seared" , "steamed" , "stinky" , "broiled" , "roasted" , "grilled" , "sauteed" , "frozen"] # Array of food name -fd_name = ["ice cream" , "soup" , "chicken" , "crab" , "beef" , "cabbage" , "potato" , "carrots" , "salad" , "lobster"] +fd_name = ["Ice Cream" , "Soup" , "Chicken" , "crab" , "beef" , "Cabbage" , "Potato" , "Carrots" , "Salad" , "Lobster"] # Create menu array to store menu items ramdomized menu = [] -10.times do |x| +menu_items.times do |x| # Will delete from array once it has been accessed, so there are no duplicated menu items. menu << "#{fd_adj.delete(fd_adj.sample)} #{fd_style.delete(fd_style.sample)} #{fd_name.delete(fd_name.sample)}" end @@ -21,14 +30,5 @@ # prints the return value of each with indeces 1-10 menu.each_with_index do |x, i| # This will print out a list starting at 1, and going until 10, as well as the randomly generated food name. -puts "#{i+1}: #{x}" -end - - -puts "\nNot seeing anything you like?" -like = gets.chomp.upcase.to_s -if like == "NO" - puts "How do you like your food cooked?" - cooked = gets.chomp.to_s - fd_style << cooked +puts "#{i+1}. #{x}" end