Skip to content

Conversation

@tfrego
Copy link

@tfrego tfrego commented Aug 7, 2018

Random Menu Generator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
For the places where arrays were used, could using a hash work? Could it work easily? Why or why not? No, a random number generator was used to reference the array indices. Numbers cannot be used to reference hashes.
Did you find repetitions of the same or similar code? Why did you have to do it that way? Yes, I needed to repeat the same code for each type of array (adjective, style, food).
Did you use any loops? If so, how did it help solve a problem? Yes, the loops helped to repeat based on the user's number of menu items provided.

@CheezItMan
Copy link

Random Menu Generator

What We're Looking For

Feature Feedback
A random menu of 10 items are displayed in the terminal Check, lets us pick the number
The code that generates the random menu pulls one random item from each array to create menu items Check
Readable code with consistent indentation Check
Summary nice work, it performs as expected. One note I left in your code was how the way you prevent duplicates can cause performance issues, we discussed that in class. Not an issue, just something to be aware of.

# generate random number for food preparation style
random_style = rand(0...number_items)
# generate new randon number if adjective has already been used
while style_numbers.include?(random_style)

Choose a reason for hiding this comment

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

This loop could theoretically go a very long time until a style not chosen before is selected. It is a potential performance issue.

Not a problem here, but you probably don't want to replicate this solution in other projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants