-
Notifications
You must be signed in to change notification settings - Fork 45
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
Tor Shimizu - Solar System - Octos #23
base: master
Are you sure you want to change the base?
Conversation
to backup file
Uploading to backup file
Solar SystemWhat We're Looking For
|
def create_planet_hash # this method ties the index +1 of the planet to the instance of the planet, for selection in the menu | ||
# @planet_hash = Hash[@planet_names.zip(@planets)] | ||
@planets.each.with_index(1) do |planet, index| | ||
@planet_hash[index] = planet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of these internal helper methods that go through and update all of the state whenever something changes. Very clever.
numbered_planets = ["0: List all summaries"] | ||
@planets.each.with_index(1) do |planet, index| | ||
numbered_planet = "#{index}: #{planet.name}" | ||
numbered_planets << numbered_planet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you could use the @planet_names
array here to simplify this code a bit.
end | ||
|
||
def get_distance # might need to convert ',' to '_' for bignums | ||
print "How far is this planet from the Sun in miles? > " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I love that you've broken all these out into separate methods, for the questions this might be a little too much functional decomposition. You've got a bunch of small methods here, but they all get called in the same sequence every time. It might be easier to follow if it was all one method.
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initialize
method in your class?SolarSystem
used anArray
vs aHash
.