From fb6b4a1aa8dafb4042aa37e11d139ea937e96d04 Mon Sep 17 00:00:00 2001 From: Lily Sky Date: Tue, 6 Feb 2018 11:12:23 -0800 Subject: [PATCH 1/5] delicious food options --- lily-random-menu.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lily-random-menu.rb diff --git a/lily-random-menu.rb b/lily-random-menu.rb new file mode 100644 index 0000000..d0c10e7 --- /dev/null +++ b/lily-random-menu.rb @@ -0,0 +1,30 @@ +# Lily's random menu generator + +# create 3 arrays of potential food list words (10 per list) +adjective = ["Spicy", "Tangy", "Tart", "Upside-down", "Salty", "Lime", "Nutty", "Sweet", "Aromatic", "Heavenly",] +style = ["sauteed", "breaded", "battered", "burnt", "toasted", "curried", "roasted", "shredded", "blistered", "poached"] +item = ["lamb chops", "pork shank", "ribs", "kale", "chicken", "turnips", "beets", "salmon", "yams", "beef"] + +# get input from user regarding number of items - must be from 1 to 10 or else will ask for number again +puts "Hello, how many menu options would you like to have today?" + +answer = 0 +until answer <= 10 && answer > 0 +print "Please choose a number from 1 to 10: " +answer = gets.chomp.to_i +puts "" +end + +# must have 10 or fewer items; if parameters are satisfied output options +if answer <= 10 && answer > 0 + puts "Fantastic! Here is your menu:" + tally = answer.to_i + 1 + i = 1 + until i == tally + +#delete contents from arrays as they are used so there are no duplicates in output + puts "#{i}. #{adjective.delete(adjective.sample)}, #{style.delete(style.sample)} #{item.delete(item.sample)}" + i += 1 + end + puts "" +end From 1583d0ac41105678585f5ba403fbf26f225d48f9 Mon Sep 17 00:00:00 2001 From: lillers1122 Date: Tue, 6 Feb 2018 11:35:28 -0800 Subject: [PATCH 2/5] Update lily-random-menu.rb --- lily-random-menu.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lily-random-menu.rb b/lily-random-menu.rb index d0c10e7..786b9af 100644 --- a/lily-random-menu.rb +++ b/lily-random-menu.rb @@ -9,10 +9,10 @@ puts "Hello, how many menu options would you like to have today?" answer = 0 -until answer <= 10 && answer > 0 -print "Please choose a number from 1 to 10: " -answer = gets.chomp.to_i -puts "" + until answer <= 10 && answer > 0 + print "Please choose a number from 1 to 10: " + answer = gets.chomp.to_i + puts "" end # must have 10 or fewer items; if parameters are satisfied output options From c313dd5ed6dc2b1cdf52b6cbe61ca8e38ba45941 Mon Sep 17 00:00:00 2001 From: lillers1122 Date: Tue, 6 Feb 2018 11:35:47 -0800 Subject: [PATCH 3/5] Update lily-random-menu.rb --- lily-random-menu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lily-random-menu.rb b/lily-random-menu.rb index 786b9af..2e97076 100644 --- a/lily-random-menu.rb +++ b/lily-random-menu.rb @@ -9,7 +9,7 @@ puts "Hello, how many menu options would you like to have today?" answer = 0 - until answer <= 10 && answer > 0 +until answer <= 10 && answer > 0 print "Please choose a number from 1 to 10: " answer = gets.chomp.to_i puts "" From d5ebf388158439d6ca4632c05be59bc9beaf0350 Mon Sep 17 00:00:00 2001 From: lillers1122 Date: Tue, 6 Feb 2018 11:42:38 -0800 Subject: [PATCH 4/5] Update lily-random-menu.rb --- lily-random-menu.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lily-random-menu.rb b/lily-random-menu.rb index 2e97076..f22eef2 100644 --- a/lily-random-menu.rb +++ b/lily-random-menu.rb @@ -16,15 +16,13 @@ end # must have 10 or fewer items; if parameters are satisfied output options -if answer <= 10 && answer > 0 - puts "Fantastic! Here is your menu:" - tally = answer.to_i + 1 - i = 1 - until i == tally +puts "Fantastic! Here is your menu:" +tally = answer.to_i + 1 +i = 1 +until i == tally #delete contents from arrays as they are used so there are no duplicates in output - puts "#{i}. #{adjective.delete(adjective.sample)}, #{style.delete(style.sample)} #{item.delete(item.sample)}" +puts "#{i}. #{adjective.delete(adjective.sample)}, #{style.delete(style.sample)} #{item.delete(item.sample)}" i += 1 - end - puts "" end + puts "" From 65d9ff6d7c3f2e65805e5ccd3b7c9e361194bc03 Mon Sep 17 00:00:00 2001 From: lillers1122 Date: Tue, 6 Feb 2018 12:23:45 -0800 Subject: [PATCH 5/5] Update lily-random-menu.rb --- lily-random-menu.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lily-random-menu.rb b/lily-random-menu.rb index f22eef2..71c7a8b 100644 --- a/lily-random-menu.rb +++ b/lily-random-menu.rb @@ -12,17 +12,20 @@ until answer <= 10 && answer > 0 print "Please choose a number from 1 to 10: " answer = gets.chomp.to_i - puts "" end -# must have 10 or fewer items; if parameters are satisfied output options +# once parameters are satisfied, output options +puts "" puts "Fantastic! Here is your menu:" -tally = answer.to_i + 1 + +# add 1 to answer value because until loop will only run up to and not including answer value. i = 1 -until i == tally +until i == answer + 1 -#delete contents from arrays as they are used so there are no duplicates in output -puts "#{i}. #{adjective.delete(adjective.sample)}, #{style.delete(style.sample)} #{item.delete(item.sample)}" +# delete contents from arrays as they are used so there are no duplicates in output + puts "#{i}. #{adjective.delete(adjective.sample)}, #{style.delete(style.sample)} #{item.delete(item.sample)}" i += 1 end - puts "" + +# stylized to have an extra space at the end +puts ""