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

Create random-menu.rb #24

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

Conversation

anemonekey
Copy link

Random Menu

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
How did you store menu components? Why? I made arrays for the menu components because it was a test in the project requirements.
Could you have stored components using a different data structure? For example, if you used an Array could you have used a Hash? For my code, using a Hash would not have been as useful as I tried to separate the relationship of each type of data (food name, adjective, etc.) and randomize them separately as well. I think Hash storage would be feasible, but maybe not as convenient.
Did you find yourself repeating the same code? Why did you have to do it that way? I repeated a random array of numbers because I wanted a random sorting order for each type of array. It looks repetitive... but I couldn't think of a way to make separately random orders for each array without this method.
What type of loop did you use? Why did you choose that type? I chose to use an n.times loop because I could ask the user for the number of items and adjust accordingly with the received integer input.

random_one = []
until random_one.length == create
num1 = rand(create)
random_one << num1 unless random_one.include? num1
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that instead of shuffling the array itself, you created a randomized list of indices. Very clever.

create.times do |n|
puts "#{n+1}. #{adjectives[random_one[n]].split.map(&:capitalize).join(' ')} #{styles[random_two[n]].split.map(&:capitalize).join(' ')} #{foods[random_three[n]].split.map(&:capitalize).join(' ')}"
end
else
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line where you output the menu selections is very similar to the one above. Is there some way you could consolidate the two?

@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 work overall! Good job on the optionals.

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