Skip to content
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
36 changes: 36 additions & 0 deletions random_menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@


# Create three arrays. One wiht adjectives, one with cooking-style and one with food.
adjectives = ["hot", "blend", "cold", "warm", "spicy",
"sweet", "sweet & sour", "bitter", "creamy", "crunchy"]
cooking_style = ["cooked", "steamed", "grilled", "boiled", "seared",
"baked", "pan-fried", "oil-fried", "simmering", "marinated"]
food = ["beef", "vegetables", "cookies", "lamb", "pasta",
"chicken", "salmon", "shrimps", "clams", "dumplings"]

descriptive_terms = [adjectives, cooking_style, food]

# Input of how many items the menue will have
print "How many items would you like to see on the menue? "
number_of_items = gets.chomp.to_i
item_number = 0

# Printing out the items one by one
number_of_items.times do

Choose a reason for hiding this comment

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

Note that a times loop gives you the current count as an iteration variable. So this loop could be rewritten as:

number_of_items.times do |n|
  # ...get adj_choise, style_choise and food_choise...
  puts "#{n+1}, #{adj_choise} #{style_choise} #{food_choise}"
end

Both ways will work, so do what makes sense for you.


item_number += 1

# Random pulled element from each of the arrays
adj_choise = descriptive_terms[0].sample
style_choise = descriptive_terms[1].sample
food_choise = descriptive_terms[2].sample

# Deletion of the pulled element
descriptive_terms[0].delete(adj_choise)
descriptive_terms[1].delete(style_choise)
descriptive_terms[2].delete(food_choise)

#Printout of the menue item
puts "#{item_number}. #{adj_choise} #{style_choise} #{food_choise}"

end