-
Notifications
You must be signed in to change notification settings - Fork 45
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
Ampers: Abinnet Ainalem (Basic requirements met) #38
base: master
Are you sure you want to change the base?
Conversation
puts "Enter anything else to take a break from learning.\n" | ||
play = gets.chomp.downcase | ||
end | ||
puts "\n Live long and prosper" |
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.
Thanks!
} ] | ||
|
||
# UI: welcomes and prompts user for input | ||
puts "Hello and welcome to Planet Gazer" |
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.
Why is this indented?!!
In the future before submitting use Atom's autoindent feature!
puts "\nType the planet name exactly as it appears below to learn more." | ||
puts "Or, enter NEW to create your own planet\n" | ||
|
||
solar_system = SolarSystem.new(planets) |
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.
A couple of things here:
- You're initializing
solar_system
with an array of hashes and NOT an array ofPlanet
instances! - You're re-creating the
SolarSystem
instance each time the loop repeats. That's a bit inefficient. Only put code in a loop that needs to be there.
current_planets = solar_system.cycle_through_system | ||
puts "\n" | ||
current_planets.each {|planet| puts planet.upcase} | ||
user_planet_choice = gets.chomp.downcase |
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.
Why show the planet names in all caps and then downcase the user entry?
# Stores an array of hashes of info on planets | ||
def initialize (planets) | ||
@planets = planets | ||
@ranked_planets = [] |
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.
Do you need 2 instance variables? This looks like it should be a local variable holding an array of planet names (and numbers).
@color = planet_info[:color] | ||
end | ||
def user_friendly_display | ||
return "\nAt #@sun_distance million miles from the sun,\nA year on the #@color planet #@name passes in #@year_length days.\n" |
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.
Good
|
||
# Cycles through list of planets | ||
# Returns numbered list of planets, w/ respect to sun proximity | ||
def cycle_through_system |
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 method should just return a list of planet names, not add elements to another instance variable. If you hadn't recreated the SolarSystem
each iteration of the main loop you would end up with double and triple entries for each planet in @ ranked_planets
.
Solar SystemWhat We're Looking For
|
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initialize
method in your class?SolarSystem
used anArray
vs aHash
.