Open
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.
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initializemethod in your class?SolarSystemused anArrayvs aHash.