Skip to content

Conversation

@amcejamorales
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? To create instance variables that could be used throughout the class.
Describe an instance variable you used and what you used it for. One instance variable I used in my SolarSystem class was @Age, which I used in my get_local_year method to determine the number of rotations a planet has done around the sun (i.e., the local year) based on the age of the solar system and the amount of time it takes the planet to go around the sun.
Describe what the difference would be if your SolarSystem used an Array vs a Hash. It makes more sense to use an array to hold the collection of planets within a solar system. The actual planets could be hashes with key-value pairs detailing their attributes, or instances of a custom class. However, if we were to add more attributes to the solar system, such as the type of star it contains, other systems in the vicinity, distance to the nearest star, etc., we could use a hash to hold all of this information. That could also be useful when dealing with various solar systems, especially to organize the information within each system rather than knowing it only contains an array of planets. If such were the case, the difference would be in how many layers of information we have to dig through to get a particular attribute. Another difference would be how we get information in loops within class methods. For an array we'd use the .each_with_index method to iterate over it. For a hash we'd use the .each method and include both the key and value between the pipes. Finally, it would be important to not mistakenly try to use a symbol in place of an iterator variable and vice versa when trying to iterate over either a hash or array and extract information from either of these using bracket notation.
Do you feel like you used consistent formatting throughout your code? Yes.

@amcejamorales amcejamorales changed the title Angelica Ceja - Solar System project completed waves 1 through 3 Angelica Ceja - Solar System - Octos Feb 12, 2018
@CheezItMan
Copy link

Solar System

What We're Looking For

Feature Feedback
Baseline
Readable code with consistent indentation. Check
Primary Requirements
Created Custom Solar System Class with initialize, add planet & list planets methods, without using puts. Check
Planet Class Created Check
Created a collection of Planet objects as an instance variable in SolarSystem. Check
Accessor methods created Check, used attr_accessor instead of attr_reader
Method created to return the Planet's attributes and not use puts Check
Created a user interface to interact with the SolarSystem including adding a planet and viewing a planet's details Check
Additional Notes Well done you hit all the requirements and several of the extras. Nice work! I left a few minor notes as in-line comments.

# class Planet lets you create a planet with various attributes and access that information individually and all-together
# part of wave 2
class Planet
attr_accessor :name, :order, :color, :temp, :water, :diameter, :moons, :year_length, :dist_from_sun

Choose a reason for hiding this comment

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

Why use attr_accessor. In general use attr_reader unless you specifically want to give the user the ability to change an attribute directly.

planet_information = ""

solar_system.planets.each do |planet|
if planet_selection == planet.name

Choose a reason for hiding this comment

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

You're comparing the entry to the Planet's name, but you print out the planet names along with a number. A user is usually expecting to enter the number to select the planet.

It's just a little counterintuitive.

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