-
Notifications
You must be signed in to change notification settings - Fork 48
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
Solar System - Leanne R #32
base: master
Are you sure you want to change the base?
Conversation
Solar SystemWhat We're Looking For
|
Rake::TestTask.new do |t| | ||
t.libs = ["lib"] | ||
t.warning = true | ||
t.test_files = FileList['specs/*_spec.rb'] |
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.
Note the Rakefile is looking for a specs
folder, but you named it spec
(singular).
|
||
#This method should create two different instances of Planet and print out some of their attributes. | ||
|
||
def main |
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 begs to be broken up into smaller methods.
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.
Okay, thanks I thought everything had to stay into main, that is the only reason why I didn't. Now I know for future.
|
||
class SolarSystem | ||
attr_reader :star_name, :planets | ||
attr_writer :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.
You shouldn't need a writer for 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.
Yes, correct, forgot to delete after tests.
|
||
# takes the name of a planet as a string, and returns the corresponding instance of Planet. The lookup should be case-insensitive. | ||
def find_planet_by_name(planet_name) | ||
@planets.each do |planet| |
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.
You can also do:
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?