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

Sockets - Amy #26

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

Sockets - Amy #26

wants to merge 7 commits into from

Conversation

aphunk
Copy link

@aphunk aphunk commented Feb 27, 2019

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
When does the initialize method run? What does it do? It runs any time a new instance of a class is created. It acts as a blueprint for that particular class of object.
Why do you imagine we made our instance variables readable but not writable? Because the Solar System project was a user-facing application accessed from the command-line, we wanted to control the input from the user to ensure it didn't affect the program's code.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? The planet creation process would have been more tedious, as each new planet’s details would have needed to be entered in a bit more manually. Additionally, a more complex data structure would need to have been established in order to access planet data—this was relatively easy using instances of a class.
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? The loop I use to call details about a user-specified planet would need to change to reference a key/value set, what that would be specifically would depend on how I structured the data.
The Single Responsibility Principle (SRP) says that each class should be responsible for exactly one thing. Do your classes follow SRP? What responsibilities do they have? Yes. The SolarSystem class is responsible for keeping track of the planets within the system; the Planet class is responsible for individual planet information.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? The main.rb file required the planet and solar system files because the data stored in each needed to be accessed by the main file. The solar system and planet files did not reference other sources because the information was self-contained.

@aphunk aphunk closed this Feb 27, 2019
@aphunk aphunk reopened this Feb 27, 2019
@droberts-sea
Copy link

Good job overall - this submission is well-organized and clearly hits the learning goals. Keep up the hard work!


solar_system.planets.each_with_index do |planet, index|
puts "#{planet.name}"
if planet.name == learn_choice

Choose a reason for hiding this comment

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

Please remove debug output (like line 37) before submitting projects.

def find_planet_by_name(planet_name)
@planets.each do |planet|
if planet.name.capitalize == planet_name.capitalize
return planet

Choose a reason for hiding this comment

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

Is there an enumerable method you could use to make this a little cleaner?

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