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 - Elizabeth Deutsch - Random Menu #43

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
56 changes: 56 additions & 0 deletions random.menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# establish 3 arrays with 10 items each. 1st array is of adjectives, 2nd array of cooking styles, 3rd array of foods.

adjectives = [
"hot",
"blue",
"warm",
"tempura",
"spicy",
"creamy",
"silky",
"sugared",
"avocado",
"salted"
]

styles = [
"wok-fried",
"pan-seared",
"flash-frozen",
"baked",
"tossed",
"grated",
"au gratin",
"riced",
"julienned",
"marinated"
]

foods = [
"salmon",
"brussel sprouts",
"cauliflower",
"spinach salad",
"tapioca",
"cake",
"green beans",
"risotto",
"beets",
"cherries"
]

print "\nMenu Items of the Day\n\n"

#generate 10 item menu, that randomly combines noun, adjective, food

count = 1

10.times do

Choose a reason for hiding this comment

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

Note that with a times loop, you get an iteration variable corresponding to the current count. So this code could be rewritten as:

10.times do |n|
  # ..get descrip, how, what...
  print "#{n+1}. #{descrip} #{how} #{what}\n\n"
end

Both ways work - use the one that you think makes the most sense to you.

Copy link
Author

Choose a reason for hiding this comment

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

This is great. Thanks for the suggestion.

descrip = adjectives[rand(adjectives.length)]
how = styles[rand(styles.length)]
what = foods[rand(foods.length)]
print "#{count}. #{descrip} #{how} #{what}\n\n"
count +=1
end