-
Notifications
You must be signed in to change notification settings - Fork 44
Ampers Week1 Sara S Solar System #36
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.