Skip to content

Conversation

@sophearychiv
Copy link

@sophearychiv sophearychiv commented Feb 27, 2019

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
When does the initialize method run? What does it do? When .new is called. Initialize creates a new instance from the class with default attributes and behaviors if they are set.
Why do you imagine we made our instance variables readable but not writable? Because we don't need to write them since we already wrote them when creating a new instance using .new.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? I would need to to use square brackets to retrieve data instead of creating an instance of the class and call the methods. I wouldn't be able to use the blueprint of the class to add new planets; instead I would need to do so by using the square brackets. Also using Class would allow me to add other behaviors as I want the planet to have. In general, class provides more flexibility.
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? If Hash is used, when storing the planet, I would need to retrieve its attributes such as name, color, mass, distance, and fun fact from the instance of class before storing them in Hash as key value pairs. And when I get the attributes of each planet, I need to use square brackets to do so instead of calling the method from each element of the array (which is an instance of the Class).
The Single Responsibility Principle (SRP) says that each class should be responsible for exactly one thing. Do your classes follow SRP? What responsibilities do they have? Yes, my classes follow SRP. Class Planet is to keep track of information about a single planet. Class SolarSystem is to keep track of the collection of instances of Planet.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? I used 'require' statements such as ' require "minitest/autorun"' and 'require "minitest/reporters"' for the purpose of testing. I put them on the top of the spec files in planet_spec.rb and solar_system.rb. I also used 'require "colorize"' to colorize the displays in my main.rb file.

@CheezItMan
Copy link

Solar System

What We're Looking For

Feature Feedback
Baseline
Whitespace (indentation, vertical space, etc) Well formatted
Overall Nicely done, you hit all the learning goals for the project. You even had time to write tests! Great work.

end

def find_planet_by_name(name)
@planets.each do |planet|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use .find to search for the planet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants