-
-
Save trowbrsa/d5348a1309c53da32b98 to your computer and use it in GitHub Desktop.
Sarah Trowbridge's Random Menu Generator. Note that the met the primary requirements were met for this project and I attempted some of the optional enhancements but the enhancements are incomplete. I am going to return to this at a later time to complete it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Welcome to the internet's most random food generator!" | |
puts "How many dishes can we tantilize you into reviewing today? Select a number between 1 and 10." | |
number_of_dishes = gets.chomp | |
if number_of_dishes.to_i > 10 | |
puts "That's a bigger number than the number of dishes our chef can cook! Please select a lower number." | |
#Need to figure out a way to have the program not continue if they select a larger number than 10. | |
elsif number_of_dishes.to_i >= 1 && number_of_dishes.to_i <=10 | |
puts "#{number_of_dishes.to_i} dishes, excellent choice!" | |
else | |
puts "That's not a number, silly. Let's go with 8 dishes!" | |
dishes = number_of_dishes.to_i | |
dishes = 8 | |
end | |
#Note - I haven't figured out a way to incorporate the users input and generate the below based on their response. | |
#I also haven't figured out to how to ensure that the user does not see repeating options. | |
adjective = ["steamy", "stinky", "smooth", "slimy", "sweet", "succulent", "aromatic", "flaky", "slippery", "bountiful"] | |
cooking_style = ["chilled", "crisp-fried", "burnt", "plucked", "skinned", "mushed", "sizzled", "smoked", "flash-fried", "frozen"] | |
food = ["squid legs", "octopus eye", "salmon scales", "shark fin", "sea snail", "baby star fish", "seaweed", "tuna sandwhich", "clam bake", "turtle head"] | |
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
adjective.shuffle.delete(adjective) | |
cooking_style.shuffle.delete(cooking_style) | |
food.shuffle.delete(food) | |
puts "Today's delicacy will be..." | |
numbers.each do |n| | |
puts "#{n}. #{adjective[rand(10)]} #{cooking_style[rand(10)]} #{food[rand(10)]}" | |
end |
Take a look at the docs for the shuffle
method. I don't think it is shuffling it the way you think it is. I think the one you would ultimately want is the shuffle!
. We haven't really talked about the differences, but the docs should explain it a bit: http://ruby-doc.org/core-2.2.0/Array.html#method-i-shuffle
Nice job with your final each
loop. Hopefully now you see how you might be able to use a range rather than create this separate numbers
array which would do the same type of thing for you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In your
else
on line 9, it seems like line 11 is not necessary since your program will ignore the user-input value and reset it to 8