-
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
Laura_solar_system #35
base: master
Are you sure you want to change the base?
Conversation
Solar SystemWhat We're Looking For
|
require_relative 'solar_system' | ||
require 'pry' | ||
|
||
def main |
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 method begs to be broken up into smaller simpler methods.
@distance_from_sun_km = distance_from_sun_km | ||
@fun_fact = fun_fact | ||
end | ||
attr_reader :name, :color, :mass_kg, :distance_from_sun_km, :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 should be above initialize and below class Planet
@planets = [] | ||
end | ||
|
||
attr_reader :star_name, :planets |
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.
ditto with above
end | ||
# map adds a nill if it does not exist | ||
def find_planet_by_name(target_planet) | ||
planets.select { |planet| return planet if planet.name.upcase == target_planet.upcase } |
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.
sweet 👍
|
||
def list_planets | ||
string = "Planets orbiting #{@star_name}: \n" | ||
list = planets.map.with_index do |planet, index| |
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.
Awesome 🥇
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?