Open
Conversation
…to main.rb so program runs. Works.
… positive numbers.
….rb to instantiate SolarSystem.
…ets. It does. Refractored SolarSystem to use the enumerable map in the list_planets method.
…ts in solar_system.rb needs to return alist so I refactored it to make it do that.
…when for adding a new planet. Created a method called new_planet in solar_system.rb.
Solar SystemWhat We're Looking For
|
dHelmgren
reviewed
Aug 29, 2019
| play = gets.chomp | ||
| puts | ||
|
|
||
| while play == "y" |
There was a problem hiding this comment.
Using this syntax is almost the same as while true. since play never gets changed, this looks like an infinite loop, which is not so good.
| end | ||
|
|
||
| def planet_details | ||
| print "Enter the name of the planet you wish to learn about: " |
There was a problem hiding this comment.
Again, this probably belongs in main.rb
| puts | ||
| when "2" | ||
| unknown_planet = solar_system.planet_details | ||
| p unknown_planet |
There was a problem hiding this comment.
p prints out some extra quotes. It looks weird!
|
|
||
| def new_planet | ||
| print "Planet's name: " | ||
| new_name = gets.chomp |
There was a problem hiding this comment.
To keep the solar_system at a single responsibility, I would move this communication with the user into your main.rb, perhaps in a helper method.
| end | ||
|
|
||
| def summary | ||
| return "#{self.name} is a #{self.color} planet that weighs #{mass_check(self.mass_kg)} kg and is #{distance_check(self.distance_from_sum_km)} km from the sun. Fun fact: #{self.fun_fact}." |
There was a problem hiding this comment.
This is a weird place to call distance_check and mass_check.
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 run? What does it do?Hashinstead of an instance of a class?SolarSystemclass used aHashinstead of anArrayto store the list of planets?requirestatements? Which files neededrequires, and which did not? What is the pattern?