Skip to content
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

Queues - Elizabeth Deutsch - Random Menu #43

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

Conversation

edeutschie
Copy link

Random Menu

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Would a hash work just as well as an Array in this project? Why? I think a hash with arrays inside of it for each menu item would have been useful because it is a way to organize key (menu item number) value (menu items) pairs.
Did you find yourself repeating the same code? Why did you have to do it that way? I repeated the code three times to randomly generate the three parts of each menu item. I did it that way because they were three separate variables that needed to be determined. They could be generated the same way, but I didn't see how to combine/simplify the code.
What type of loop did you use? Why did you choose that type? I used a times loop because I knew exactly how many times I wanted to run the block of code.

Copy link

@droberts-sea droberts-sea left a comment

Choose a reason for hiding this comment

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

Random Menu

What We're Looking For

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

Good work overall!


count = 1

10.times do

Choose a reason for hiding this comment

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

Note that with a times loop, you get an iteration variable corresponding to the current count. So this code could be rewritten as:

10.times do |n|
  # ..get descrip, how, what...
  print "#{n+1}. #{descrip} #{how} #{what}\n\n"
end

Both ways work - use the one that you think makes the most sense to you.

Copy link
Author

Choose a reason for hiding this comment

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

This is great. Thanks for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants