-
Notifications
You must be signed in to change notification settings - Fork 49
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
Branches - Vi Reigosa #42
base: master
Are you sure you want to change the base?
Conversation
Solar SystemWhat We're Looking For
Vi! Well done on this project! You did a great job on this project. In particular, your practice on object-oriented programming and creating classes with the right instance variables and instance methods is great! It looks exactly how I would want it to look There's opportunity to see what parts of the That being said, well done overall; keep up working with and getting comfortable with classes, instances, instance variables within a class, and instance methods! |
require_relative 'solar_system' | ||
|
||
def main | ||
earth = Planet.new('Earth', 'Blue-green', 5.972e24, 1.496e8, 'Only planet known to support capitalism :/') |
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.
rip
|
||
def main | ||
earth = Planet.new('Earth', 'Blue-green', 5.972e24, 1.496e8, 'Only planet known to support capitalism :/') | ||
venus = Planet.new('Venus', 'Pink', 8.6e24, 2.36e8, 'Gayest planet probably!') |
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.
:)
puts found_planet.summary | ||
else | ||
puts "thats not a planet name, sorry buddy try again!" | ||
next |
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.
Nice! Clever way to make this work
|
||
if vega.find_planet_by_name(new_planet_name) != nil | ||
puts "that planet already exists >:( try another" | ||
next |
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.
Nice!
end | ||
|
||
def list_planets | ||
allplanets = "" |
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.
Minor nitpick: Ruby naming standards would probably format this as all_planets
|
||
return planets.find { |planet| | ||
planet.name.downcase == planet_name.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.
Well done! Using .find
means that if the planet wasn't found, it will return nil
, which gets used appropriately in main
.
|
||
return planets.find { |planet| | ||
planet.name.downcase == planet_name.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.
Just for the thoroughness of seeing many kinds of syntax (I have no preference), I want to share that this syntax is the same:
return planets.find do |planet|
planet.name.downcase == planet_name.downcase
end
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initialize
method run? What does it do?Hash
instead of an instance of a class?SolarSystem
class used aHash
instead of anArray
to store the list of planets?require
statements? Which files neededrequire
s, and which did not? What is the pattern?