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

Queues - Cara Comfort - Solar System #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cecomfort
Copy link

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What was the purpose of the initialize method in your class? Using the 'initialize' method in my Planet and Solar System classes allows me to define instance variables pertaining to each class when the "new" method is called outside of the class. When "new" is called, an instance of each class is created with an inherit set of properties, defined by the instance variables.
Describe an instance variable you used and what you used it for. One of my instance variables for my planet class was planetary year, meaning the length of one year on that planet in earth days. I used this instance variable in a Planet method to help provide information on a given instance of the Planet class. I also used it in my Solar System class to calculate the age of a planet based on the formation year of a given solar system object.
Describe what the difference would be if your SolarSystem used an Array vs a Hash. Using a hash instead of an array would have improved the readability of my code and simplified it to some extent. I would have no longer needed the find_planet method, which when given a string of a planet name, finds the planet in the solar system array and returns the corresponding planet object. If I used a hash when initializing my solar system, I could have just used the planet name as a key instead of having to look up where the planet was in my solar system array.
Do you feel like you used consistent indentation throughout your code? Yes, I do.

@cecomfort cecomfort changed the title Create solar-system.rb Queues - Cara Comfort - Solar System Feb 15, 2017
@droberts-sea
Copy link

Solar System

What We're Looking For

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

Good code organization. Excellent work on the optionals!


# Returns a string of information on the planet
def get_planet_info
"#{@name} has a mass of #{@mass} kilograms, a mean diameter of " +

Choose a reason for hiding this comment

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

I like that you return a value here rather than puts-ing it. This will make the method more useful from other parts of your code.

attr_reader :name, :moons, :sun_distance, :planetary_year, :mass, :diameter,
:temp, :gravity

def initialize(planet_hash)

Choose a reason for hiding this comment

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

Good job re-working Planet#initialize to take a hash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants