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 :/') |
|
|
||
| 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!') |
| puts found_planet.summary | ||
| else | ||
| puts "thats not a planet name, sorry buddy try again!" | ||
| next |
|
|
||
| if vega.find_planet_by_name(new_planet_name) != nil | ||
| puts "that planet already exists >:( try another" | ||
| next |
| end | ||
|
|
||
| def list_planets | ||
| allplanets = "" |
There was a problem hiding this comment.
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.
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.
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
initializemethod run? What does it do?Hashinstead of an instance of a class?SolarSystemclass used aHashinstead of anArrayto store the list of planets?requirestatements? Which files neededrequires, and which did not? What is the pattern?