Skip to content

Create menu_generator.rb #33

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bennettrahn
Copy link

Random Menu

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
How did you store menu components? Why? Arrays, because I needed to store multiple objects of a similar type in the same place.
Could you have stored components using a different data structure? For example, if you used an Array could you have used a Hash? Yes - but essentially it would be a hash with three keys and also the arrays because I needed the arrays to call them randomly, so it felt sort of unnecessary. Could be wrong.
Did you find yourself repeating the same code? Why did you have to do it that way? No, unless you count me copying it for the different versions/adaptations. I did notice that in my .times loop I defined the variable 'item' but I'm not sure I needed to do that - I could have just put all the interpolators in the puts statement, but it looked so messy and confusing that way, so I kept the potentially unnecessary variable declaration.
What type of loop did you use? Why did you choose that type? I used both the .times and .until loops in various versions. The .times allowed me to manipulate the code for the 'user input of number of items' version. Potentially I could have used a .each for the first version, but I didn't because I foresaw the need for .times. I used the .until in the loop that repeats until the user puts in a number my arrays have enough objects for.

@droberts-sea
Copy link
Collaborator

Random Menu

What We're Looking For

Feature Feedback
Random Menu of 10 items displayed in the terminal. yes
Generator pulls one random item from each array to create menu items. yes
Baseline
Readable code with consistent indentation. yes

Great job overall. Good work on the optionals you did complete.

## initial assignment
10.times do |n|
item = "#{adj[rand(9)]} #{cooked[rand(9)]} #{food[rand(9)]}"
puts "#{n+1}. #{item}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're right that you don't strictly need item here. However, it never hurts to break a complex bit of code up into multiple lines / variables. This can often make it much easier to read and to reason about.

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