Skip to content
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

Ports - Ngoc #32

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Ports - Ngoc #32

wants to merge 9 commits into from

Conversation

lebaongoc
Copy link

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
When does the initialize method run? What does it do? Initialize method runs when a new instance of the class is created. It is used to construct an object
Why do you imagine we made our instance variables readable but not writable? We would make an instance variable only readable when we want to return an instance variable to be used for different methods in a class instead of overriding the value of such instance variable
How would your program be different if each planet was stored as a Hash instead of an instance of a class? If each planet was stored as a hash instead of an instance of a class, the planet hash would require repeated manual entries of keys such as names, colors, etc. (i.e, earth = {name:earth, color: blue})
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? Hash does not require as much up-front work as class. However, if we want to model different behaviors of planets in the class SolarSystem then using class would be better in the long run as the class methods are versatile and can be used over and over again unlike with Hash where we might need to write more code to add planet or list them in a string format.
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? My two classes: Planet and Solar System, follow the SRP. Class Planet is the blueprint for creating instances of a planet while class SolarSystem is responsible for keeping track of a 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 only use require statement for the main.rb file. Planet.rb and solar_system.rb do not need a require statement. The pattern here is that a require statement is used for the main file where we create new instance using the class from the other files (planet.rb & solar_system.rb)

@CheezItMan
Copy link

Solar System

What We're Looking For

Feature Feedback
Overall Excellent work! You hit all the learning goals for the project and even had time to write a test. Nice work. See my inline notes and let me know if you have questions.

@planets.find { |planet| planet.name.downcase == planet_name.downcase }
end

def user_added_planet

Choose a reason for hiding this comment

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

I would suggest moving this method to the main.rb file so to separate the user interface role from the role of storing and organizing the planets.

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