Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions solarsystem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class SolarSystem

attr_accessor :name, :distance_from_the_sun

def initialize(info_hash)
@name = info_hash[:name]
@distance_from_the_sun = info_hash[:distance_from_the_sun]
@planets = []
end

def add_planet(planet)
@planet.push(planet)
end

def add_array(array_planet)
array_planet.each do |planet|
@planet.push(planet)
puts planet.name
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this end will be closing the SolarSystem class and then the print_array method will be outside of the method which I don't think you intended.


def print_array
@planets.each do |planet|
puts planet.name
end
end