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 - Erica J. Case - Random Menu #39

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
55 changes: 55 additions & 0 deletions Random-Menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

# a list of ten adjectives to describe food
adj = [
"artisanal",
"soylent",
"creamy",
"fresh",
"spicy",
"tough",
"imaginary",
"raw",
"gluten-free",
"fleshy"
]

# stores 10 way to prepare food
prep = [
"sauteed",
"deep-fried",
"boiled",
"stir-fried",
"baked",
"broiled",
"poached",
"pan-seared",
"steamed",
"mashed"
]
# ten foods

foods = [
"calamari",
"sirloin",
"carrots",
"gouda",
"apple",
"tacos",
"ice cream",
"corndog",
"rice",
"soy nuts"
]

# instead of generating a bunch of random numbers, I am shuffling the arrays

adj.shuffle!
prep.shuffle!
foods.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.


puts "\n"
# prints 10 random combination of adjectives
foods.length.times do |index|
puts "#{index + 1}: #{adj[index]} #{prep[index]} #{foods[index]}"
end
puts "\n"