-
Notifications
You must be signed in to change notification settings - Fork 48
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
Amber Lynn - Edges - Solar-System #39
base: master
Are you sure you want to change the base?
Conversation
…readers to exclude @ - syntax error
…olar_system.rb ¯\_(ツ)_/¯
…ning in another class
… string; making it difficult to retrieve other information about object
… user planet to @planets array
Solar SystemWhat We're Looking For
|
elsif user_input == "3" | ||
puts "Name a planet: " | ||
user_planet_name = gets.chomp | ||
puts "Color: " |
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 work is complex enough it would probably make sense to put it in a separate method.
@planets.length.times do |i| | ||
if planet_name.downcase == @planets[i].name.downcase | ||
# matching_planet = @planets[i] | ||
#cant figure out how to call summary method |
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 definitely solves the problem, but we could clean this code up a little by using an enumerable:
def find_planet_by_name(planet_name)
planet_name = planet_name.downcase
return @planets.find { |planet| planet.name.downcase == planet_name }
end
end | ||
end | ||
return x.summary | ||
end |
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.
Instead of returning the summary here, you should return the planet itself. Then whoever calls this method can do what they want with it. That might be printing the summary, comparing it with another planet, etc.
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.
Also, I think this will not quite work if the planet is not found.
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?