Skip to content

Earth - Beauttie#31

Open
beauttie wants to merge 6 commits intoAda-C14:masterfrom
beauttie:master
Open

Earth - Beauttie#31
beauttie wants to merge 6 commits intoAda-C14:masterfrom
beauttie:master

Conversation

@beauttie
Copy link

Assignment Submission: Solar System

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
When does the initialize method run? What does it do? When you use the .new method on a class name, it constructs an instance of the class with the given arguments.
Why do you imagine we made our instance variables readable but not writable? So that the user cannot modify the value of our instance variables.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? The .summary method would get the value of its corresponding attribute with its key.
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? I would need to modify the value of @planets in the constructor to be an empty hash and the body of my add_planet method to @planets[:name] = planet.name. I would also need to iterate over key-value pairs in the list_planets and find_planet_by_name methods.
There is a software design principle called the SRP. 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 followed SRP because the Planet class was responsible for reading out information about a planet and the SolarSystem class for managing information about a collection of planets.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? I put them at the top of my Ruby files. Files that needed a "require" statement used a method from the class referenced.

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.

1 participant