Skip to content

Space - Jessica Stone#41

Open
seaweeddol wants to merge 22 commits intoAda-C13:masterfrom
seaweeddol:master
Open

Space - Jessica Stone#41
seaweeddol wants to merge 22 commits intoAda-C13:masterfrom
seaweeddol:master

Conversation

@seaweeddol
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 are creating a new class. It makes you include the required parameters in your new class, and saves them as instance variables.
Why do you imagine we made our instance variables readable but not writable? The program does not require that the variables to be reassigned at any point - so they do not need to be writable.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? Instead of being able to use "@name, @color" etc, the syntax would need to be something like "planet[:name], planet[:color]". I would also need to change my syntax for creating a planet since it would no longer be able to use the constructor method that is currently being used by the Planet class.
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? I think I would need to use more nested loops to access data.
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? The Planet class follows this, as it only initializes a planet and prints a summary of that information. The SolarSystem has multiple methods, but is overall responsible for a single concept - adding planets to the solar system and providing information about the planets and their relationship to each other.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? The solar_system.rb file required the planet.rb file as it references methods to look up planets and create planets. The main.rb file requires each of the Class files solar_system.rb and planet.rb as it uses the methods and creates those classes. The test.rb references each of the Class files in order to test the methods, and the Rakefile references the test.rb file in order to run all of the tests with the Rake keyword.

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