Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queues - Tamiko Terada - Random Menu #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions random_menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# random_menu assignment from 02.08.2017
# by Tamiko Terada

puts "OH-SO-SEATTLE MENU GENERATOR"
# create new array of 10 descriptors
descriptor = [
"pan-seared",
"sous-vide",
"farm-raised",
"organic",
"local",
"rosemary-infused",
"a duet of",
"crispy",
"fire-roasted",
"ethically-raised"
]
# create new array with 10 meats
meat = [
"duck breast",
"dungeness crab",
"venison",
"filet mignon",
"rabbit",
"sockye salmon",
"Wagyu beef sirloin steak",
"Carlton Farm pork",
"lamb shank",
"albacore tuna"
]
# create new array with 10 pairing items
pairing = [
"hand-foraged wild onions",
"summer squash succotash",
"tri-colored kale",
"wild woodland mushrooms",
"oven-roasted beets",
"garlic and chive aioli",
"grilled radicchio",
"honey-roasted sunchokes",
"frangelico-blackberry compote",
"butternut squash rissoto"
]
# replace each array with shuffled array
descriptor.shuffle!
meat.shuffle!
pairing.shuffle!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of shuffle! This is a clever way to get a random order without destroying the array as you go along.

# prompt user to enter in number of items
print "How many items do you want to see? > "
number_items = gets.to_i # accept input as integer
# only accept input that is between 1 and 10
until number_items > 0 && number_items <= 10 do
print "Please enter 1 ~ 10 > " # re-prompt for input
number_items = gets.to_i
end
# verify number to user / subheading
puts "Got it! Here are your #{number_items} items:"
# loop as many times as user specified
number_items.times do |position| # iteration variable
# number the menu items with array position + 1 (since it starts w/0)
print "#{position + 1}. "
# print the shuffled arrays according to the position
puts "#{descriptor[position]} #{meat[position]} with #{pairing[position]}"
end
puts "Bon appetite!"