Conversation
Solar SystemWhat We're Looking For
For this submission, I only looked at the file Good job on the project, it runs as expected Right now, the container for my_solar_system = SolarSystem.new(planet_arr)class SolarSystem
def initialize(planets)
@planets = planets
end
#...
endThe Also I'm adding a comment about a small bug in your code :) Good work! |
| puts "You did not enter a valid option. Goodbye" | ||
| end | ||
|
|
||
| end |
There was a problem hiding this comment.
the code starting at line 103 through the end of the file should read instead:
planet_arr.each_with_index do |planet, i|
puts "#{i+1}. #{planet.summary} "
end
else
puts "You did not enter a valid option. Goodbye"
end| learn_option = gets.chomp.to_i | ||
| end | ||
| end | ||
| puts planet_arr[learn_option-1].summary |
There was a problem hiding this comment.
starting at line 81, you have a small bug!
when gets.chomp.to_i executes on line 81, if I type in a non-integer (like "asdlfkjasdf"), then the value of learn_option will default to 0.
Because learn_option is 0, it will skip over the until block on line 83, and then jump straight to line 93. if learn_option is 0, then planet_arr[0-1] will mean planet_arr[-1], which will always choose the last element in the array.
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initializemethod in your class?SolarSystemused anArrayvs aHash.Array, I can used the index to order the array, which I found helpful in wave 3. TheHashcould be helpful in keeping track of the attributes of each planet and adding additional attributes.