Skip to content

Conversation

@hanalways
Copy link

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
When does the initialize method run? What does it do? The "initialize" method was established in my solar_system.rb file (line 8), but run in my main.rb when I invoke "main" method (line 59), which instantiates a new SolarSystem class, solar_system (line 18).
Why do you imagine we made our instance variables readable but not writable? An attribute writer allows setting and resetting an instance variable outside the class, whereas an attribute reader only allows these instance variables to be read outside the class. In my application I want these instance variables to stay immutable.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? If I stored every planet as a hash instead of instance of class I would have to use different syntax and keys to access each value. Furthermore, you would not be able to add two planets of the same name, as every key has to be independent.
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 have to refactor my code to allow for each entry of planet to be stored as a key-value pair, where the value would have to be the instance of the class and the key being unique keys for each planet.
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? The Planet class is only responsible for organizing the information of the planets to spit out a summary when invoked. The SolarSystem class is responsible for storing new instances of Planet class and indexing these Planets for a search.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? All require statements were presented at the very top of each file. Both solar_system.rb and planet.rb required the Terminal Table gem to prettify existing information that was returned to my main method. main.rb required_relative both planet.rb and solar_system.rb to access both file's information.

@droberts-sea
Copy link

Good job overall - this submission is well-organized and clearly hits the learning goals. Keep up the hard work!

def new_planet
puts "What is the planet's name?"
name = gets.chomp
puts "What is the planet's color?"

Choose a reason for hiding this comment

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

This code to interact with the user might fit better in main.rb than here in SolarSystem.

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