Skip to content
Open
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions random_menu_generator_v1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Random Menu Generator
# produces random Menu
# with user-selected number of items

# produces 3 arrays with food descriptors
adjectives = ["spicy", "tangy", "sweet", "seasonal", "crunchy", "sour", "soft", "creamy", "brittle", "cold"]
cooking_style = ["sauteed", "fried", "frozen", "seared", "pan-fried", "well-done", "baked", "stir-fried", "steamed", "curried" ]
food = ["cake", "tacos", "pizza", "ice cream", "clams", "tater tots", "chicken tenders", "tuna", "steak", "tofu"]

# asks user for number of menu items (10 or fewer)
puts "How many items would you like on your menu? Please choose a value less than or equal to 10."
items = gets.to_i

# confirms whether user input is valid
while items <= 0 || items > 10
puts "Please provide a number less than 10 and greater than 0"
items = gets.to_i
end

# creates list of non-repeating numbered menu items
puts "Great! Here is your Menu:"
adjectives = adjectives.shuffle
cooking_style = cooking_style.shuffle
food = food.shuffle
items.times do |n|
puts "#{n+1}. #{adjectives[n]} #{cooking_style[n]} #{food[n]}"
end
36 changes: 36 additions & 0 deletions random_menu_generator_v2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Random Menu Generator
# produces random Menu
# with user-selected number of items

# Introduces Menu Generator
puts "Welcome to the Random Menu Generator"
puts "How many items would you like on your menu? (please choose a number less than 10 and greater than 0)"
items = gets.to_i

# confirms whether user input is valid
while items <= 0 || items > 10
puts "Please provide a number less than 10 and greater than 0"
items = gets.to_i
end

# instantiate empty arrays
adjectives, cooking_style, food = [], [], []

# produces items arrays based on user input
items.times do |n|
puts "Please provide an adjective to describe food"
adjectives[n] = gets.chomp
puts "Please provide a cooking style to describe food"
cooking_style[n] = gets.chomp
puts "Please provide a food"
food[n] = gets.chomp
end

# creates list of non-repeating numbered menu items
puts "Great! Here is your Menu:"
adjectives = adjectives.shuffle
cooking_style = cooking_style.shuffle
food = food.shuffle
items.times do |n|
puts "#{n+1}. #{adjectives[n]} #{cooking_style[n]} #{food[n]}"
end