-
Notifications
You must be signed in to change notification settings - Fork 44
Ari Herman- Solar System- Octos #32
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
base: master
Are you sure you want to change the base?
Conversation
Solar SystemWhat We're Looking For
|
| num = 1 | ||
| @planets.each do |arr| | ||
| print "\n#{num}. #{arr.summary} ".cyan | ||
| num += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced by the name of the block parameter here. arr is not very descriptive - it's not clear to the reader what type of thing you expect it to be. Calling it something like planet might be a better choice.
| @@ -0,0 +1,146 @@ | |||
| # Solar System project -create an object which contains a | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruby files should be named using snake_case. So this one would be solar_system.rb.
The choice is somewhat arbitrary, but when we start working on group projects it will be important for all of us to be doing the same thing.
| case info | ||
| when "Earth" | ||
| puts earth.summary.green | ||
| when "Mercury" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This strategy of using a switch statement makes it difficult to add new planets. Could you do something like adding a method to SolarSystem to look up a planet by name? That would allow you to show info for user planets as well.
| end | ||
| # Add the planet to the SolarSystem class | ||
| planets.push(new_name = Planet.new(new_name, new_color, new_orbit, new_diameter, | ||
| new_distance)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the new planet to planets works, but it's not great form. The purpose of SolarSystem is to keep track of our list of planets, and it's a little confusing to modify the list directly from outside. Instead, you could define a method add_planet on SolarSystem that takes an instance of Planet and adds it to the list.
|
|
||
| planets.each do |x| | ||
| puts "#{num}. #{x.name}".cyan | ||
| num += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another place where it might make sense to define a method on SolarSystem rather than accessing the list of planets directly.
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initializemethod in your class?SolarSystemused anArrayvs aHash.