From 0be14ad81510fd3d859c17ece0f1cdbbfe655429 Mon Sep 17 00:00:00 2001 From: Risha Date: Thu, 1 Oct 2015 11:23:50 -0700 Subject: [PATCH] Add file solar system --- solarsystem.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 solarsystem.rb diff --git a/solarsystem.rb b/solarsystem.rb new file mode 100644 index 00000000..5021bbe7 --- /dev/null +++ b/solarsystem.rb @@ -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 + + def print_array + @planets.each do |planet| + puts planet.name + end + end