-
Notifications
You must be signed in to change notification settings - Fork 49
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
Leaves - Elizabeth #48
base: master
Are you sure you want to change the base?
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
|
play = gets.chomp | ||
puts | ||
|
||
while play == "y" |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird place to call distance_check
and mass_check
.
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initialize
method run? What does it do?Hash
instead of an instance of a class?SolarSystem
class used aHash
instead of anArray
to store the list of planets?require
statements? Which files neededrequire
s, and which did not? What is the pattern?