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

Jou-Jou's Solar System Program #24

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

Conversation

jjousun
Copy link

@jjousun jjousun commented Feb 15, 2017

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What was the purpose of the initialize method in your class? The initialize method is the method for what happens when you create a new instance of the class. So when you do a .new on the class, initialize will set all the instance variables to whatever argument you passed into the parameter for initialize. Of course, if you didn't set any parameters, then initialize will probably have some preset values. For this program, the values that were set were, for example, the name of the planet, its diameter, its mass, etc.
Describe an instance variable you used and what you used it for. One instance variable I used was @name. This was used for the initialize constructor, which set the variable to name of the planet passed in when I created a new planet. @name was also used for the method I created to print all the information of a planet, so it was interpolated into the printed sentence.
Describe what the difference would be if your SolarSystem used an Array vs a Hash. Hmm, well, my SolarSystem Class did use an array to store all of its planets. I suppose if I used a hash it would need key values for each planet passed into the SolarSystem. So then it would be a hash of hashes. Then the method for printing planet info would change, too, in that I would probably call on each value to print. (I'm not sure I answered this question correctly -_- )
Do you feel like you used consistent indentation throughout your code? Yes, I think so!

@CheezItMan
Copy link

CheezItMan commented Feb 17, 2017

Solar System

What We're Looking For

Feature Feedback
Created Custom Class with initialize method & instance variables. Done, nice work with the hash to initialize Planet instance variables.
Used an Array to store a list of planets in the SolarSystem class. Done
Readable code with consistent indentation. Done
Created a pull request with your name & a meaningful message. Done

Summary

Nice work combining the SolarSystem's print_all method and Planet's print_info to output the SolarSystem. Very DRY.

Also if you'd used a hash instead of an array finding a planet, having known the key would be faster, but to iterate (loop) through the list of planets you would need to use the .keys method and loop through the list of keys.

Overall a very nice job.

BTW: The Milky Way is a Galaxy not a Solar System. :D

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