Skip to content

Conversation

@Jackiesan
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? Initialize defines the parameters for when a new object of that class is created. Initialize will always be called when using .new of an object in that class.
Describe an instance variable you used and what you used it for. I used name along with 5 other planet attributes as instance variables. I used instance variables to access the corresponding values of each instance. For example, I created a method to print a summary of all the instance variables which when called it prints a summary of the corresponding planet.
Describe what the difference would be if your SolarSystem used an Array vs a Hash. When SolarSystem uses a hash, you need to specify the key to the assigned value. When SolarSystem uses an array, the instance variables are assigned by order of the initialize arguments.
Do you feel like you used consistent formatting throughout your code? Yes

@CheezItMan
Copy link

Solar System

What We're Looking For

Feature Feedback
Baseline
Readable code with consistent indentation. Nicely readable with good alignments
Primary Requirements
Created Custom Solar System Class with initialize, add planet & list planets methods, without using puts. NOPE You're having methods that should return a value, do puts instead. See my inline comments.
Planet Class Created Check
Created a collection of Planet objects as an instance variable in SolarSystem. Check
Accessor methods created Check, but do you need to make them attr_accessor? Would an attr_reader work just as well?
Method created to return the Planet's attributes and not use puts NOPE this method or methods should return values instead of doing puts inside Planet.
Created a user interface to interact with the SolarSystem including adding a planet and viewing a planet's details Check, well done
Additional Notes See my in-line notes, you are mixing concerns a bit having the classes deal with their subjects and also handling display issues. Not a huge issue at present. It's just a good idea to have each class deal with a "single concern." So each class deals with one thing. SolarSystem deals with storing planets and returning a list of planet names. Planet deals with tracking information about a single planet and doing calculations regarding one planet. The main program can deal with I/O. Overall you did pretty well, more will come with practice.

planet_names << "#{i+1}. #{planet_name.name}"
i += 1
end
puts planet_names

Choose a reason for hiding this comment

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

This method should return planet_names not puts!

That way SolarSystem just returns the information the user decides what to do with it.

@mean_temp = input_mean_temp
end

attr_reader :name, :diameter, :distance_from_sun, :orbit_period, :moons, :mean_temp

Choose a reason for hiding this comment

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

This should for readability be up at the top above initialize

attr_reader :name, :diameter, :distance_from_sun, :orbit_period, :moons, :mean_temp

def planet_summary
puts "\nHere are some fun facts about #{@name}:

Choose a reason for hiding this comment

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

Again this should be a return and not a puts


end

def add_planet

Choose a reason for hiding this comment

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

The act of adding a planet to the list should be in SolarSystem because we want the SolarSystem to be responsible for what planets are in the list. Having a method outside the class to create the planet and do the prompting is good however.

print "Enter the number of your choice: "

# User will get error if they don't enter a valid choice (1,2 or 3)
selection = valid(3)

Choose a reason for hiding this comment

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

Nice method!

# User prompted to enter new planet information
new_planet = add_planet
objects_of_planets_class.push(new_planet)
else selection == 3

Choose a reason for hiding this comment

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

The else selection == 3 is not really a thing. Do you mean elseif?

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