From 9d00f093cfa1bfa96f07cdf3673c57c3d3ea8d50 Mon Sep 17 00:00:00 2001 From: Rebecca Tolmach Date: Thu, 1 Oct 2015 11:23:18 -0700 Subject: [PATCH] Add solar system file --- solar-system.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 solar-system.rb diff --git a/solar-system.rb b/solar-system.rb new file mode 100644 index 00000000..8f662180 --- /dev/null +++ b/solar-system.rb @@ -0,0 +1,33 @@ +class SolarSystem # class named SolarSystem is created + attr_reader :name, :star, :life # class has an attribute of planets + + def initialize(solar_info) + @name = solar_info[:name] + @star = solar_info[:star] + @life = solar_info[:life] + @planets = [] # makes an array + end + + def add_planet(planet) + @plantes.push(planet) + end + + def add_planet_array(planet_array) + planet_array.each do |planet| + @planets.push(planet) + end + end + + def print_out + puts "This solar system is called #{@name}. It is inhabited by" + puts "#{@life} and their sun, #{@star}, keeps them warm." + end +end + +# solar_info = {name: "Crazy", +# star: "disco ball", +# life: "toddlers" +# } +# +# crazy = SolarSystem.new(solar_info) +# puts crazy.print_out