Skip to content

Conversation

@LetiTran
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? My initialize method on class SystemSolar purpose is to accept an argument that contains an array with all the solar system information and create instance variables from it. My other initialize method, in the class Planet accepts several arguments, each containing an important information about one single planet that was previously chosen by the user and also creates necessary instance variables.
Describe an instance variable you used and what you used it for. My class SolarSystem has a instance variable called "names" and it's purpose is to hold an array with all the planets' names that this solar system contains, in order to: 1 - Display a list of only names of the planets). 2 - Assist on verifying if user input is correct when asked to choose a planet to learn more about (display planets information) 3 - Assist on verifying if user input is correct when creating a new planet (make sure the name doesn't already exists) 4 - Assist on verifying if user input is correct when selecting which planet to calculate the distance between.
Describe what the difference would be if your SolarSystem used an Array vs a Hash. I am a bit confused here. My code does contain an array with hashes. I started with a hash and later thought I was supposed to change it to an array. When using a hash instead of the array it was easy to go trough the planets by using keys and values on my loops or simply returning an array of keys. Despite using an array on my code, I did not use indexes to find the information I needed. I supposed I could've created several objects and initiated them on the classes and then looped thought the indexes to retrieve information.
Do you feel like you used consistent formatting throughout your code? Yes, I just feel like it is way too long. Extra Comments: Now that I have gone trough this questions, I am afraid I may have misunderstood what it was asking in relation to the SolarSystem class. I thought I was supposed to pass a collection into it but now I am not so sure if I did it the way you were expecting.

@LetiTran LetiTran changed the title Created my Solar System. (Ampers) Leticia Tran - Solar System 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. A bit mixing of role, see my summary
Planet Class Created Check
Created a collection of Planet objects as an instance variable in SolarSystem. Check
Accessor methods created Check
Method created to return the Planet's attributes and not use puts See my summary
Created a user interface to interact with the SolarSystem including adding a planet and viewing a planet's details Check, well done
Summary Nicely done, you hit all the requirements. However you're mixing roles a bit. Generally we want to have each class deal with one concept. Both classes are handling dealing with information on a Planet and SolarSystem and methods that can act on such information along with dealing with the user to get input and send output. This makes each class harder to change and bulkier. It would be better to have either a separate UI class or just independent methods in the main program. Let me know if that doesn't make sense. Overall nicely done.


def initialize(planets_array)
@solar_system = planets_array
@names = []

Choose a reason for hiding this comment

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

Does this need to be an instance variable? It looks like it could be used instead as a local variable in create_names.


# Grab only th names of planets from the planets_array and push it to the new array @names:
def create_names
@solar_system.each do |planets_data|

Choose a reason for hiding this comment

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

If I call create_names twice I'll end up with my list doubled!

end
end

def return_planets_name_variable #how to make this betteR?

Choose a reason for hiding this comment

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

maybe just call it planet_names


attr_reader :name, :year_length, :distance_from_the_sun, :planet_type, :interesting_fact1, :number_of_moons, :interesting_fact2

def initialize (name, year_length, distance_from_the_sun, planet_type, interesting_fact1, number_of_moons, interesting_fact2)

Choose a reason for hiding this comment

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

best not to put a space between initialize and the (

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