Skip to content

Time- Mair H#27

Open
mheshmati-tech wants to merge 1 commit intoAda-C13:masterfrom
mheshmati-tech:master
Open

Time- Mair H#27
mheshmati-tech wants to merge 1 commit intoAda-C13:masterfrom
mheshmati-tech:master

Conversation

@mheshmati-tech
Copy link

@mheshmati-tech mheshmati-tech commented Feb 20, 2020

…m while main.rb is a method to utilize those classes

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? initialize also known as the constructor, is at the beginning of the class. Whenever you need a new instance, the class will internally call on initialize to create a new object with allocated attributes.
Why do you imagine we made our instance variables readable but not writable? So the user can't change the planets later on; writable attributes can be totally changed and replaced by the user at any point if they wish to.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? I would have to loop over each planet every time I needed to retrieve information about each planet. This will create redundancy and too much coding:/
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? It would be more complicated since for the method where I list my planets, I wouldn't be able to simply shovel in each planet into the array and would need to assign the name of the planet as key while the characteristics would have to be in the value as an array. And later on, looping over them to find the information needed would be more work than just using an array.
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. Planet is responsible for taking in the name, color, mass, distance from the sun, and a fun fact about the planet and giving out a summary; while SolarSystem is responsible for adding the planets to the solar system, listing them, and finding them by their name.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? my main.rb requires the two other files which contain my classes (planet.rb and solar_system.rb). generally the rule of thumb (from my understanding) is that if you're going to use a method/instance/variable/data that was defined/located in another file, that file needs to be required to the computer knows what you're referring to when you call for that method/instance/variable/data.

…m while main.rb is a method to utilize those classes
@mheshmati-tech mheshmati-tech changed the title added main.rb, planet.rb which are classes representing a solar syste… Time- Mair H Feb 20, 2020
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