Skip to content

Conversation

@AngelaOh
Copy link

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
When does the initialize method run? What does it do? It runs when we create an instance of a class (.new). It assigns values to the instance variables.
Why do you imagine we made our instance variables readable but not writable? Planets and solar systems already exist and its info should not change based on user inputs.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? The program would be lighter but would not have any behaviors like listing the summary.
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? We would have to write more code to find a planet or list the planet when running the code (in main.rb).
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 planets class holds information on individual planets and my solar system class holds information on the entire solar system which includes the individual planets.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? The file running all the methods and classes needed a require statement - main.rb. I did not need require statements in planets.rb or solar_system.rb because they don't pull variables or information directly from other files.

@kaidamasaki
Copy link

Solar System

Nice work! Your Planet and SolarSystem classes look great!

One small thing is that your ternaries in Planet's initialize are a little on the long side and kind of hard to read, I would consider refactoring those into a normal if/else.

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