From 212f31d67ed4eda2f0dd1255041660f54d2a8b0d Mon Sep 17 00:00:00 2001 From: Amy Hunter Date: Thu, 1 Oct 2015 11:23:19 -0700 Subject: [PATCH] Add solar system files --- planet.rb | 13 +++++++++++++ solar-system.rb | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 planet.rb create mode 100644 solar-system.rb diff --git a/planet.rb b/planet.rb new file mode 100644 index 00000000..206cfa5c --- /dev/null +++ b/planet.rb @@ -0,0 +1,13 @@ +class Planet + attr_accessor :name, :diameter, :mass, :number_of_moons + def initialize(name, diameter, mass, number_of_moons) + @name = name + @diameter = diameter + @mass = mass + @number_of_moons = number_of_moons + end + + def print_out + puts "The planet #{@name} has a diameter of #{@diameter}, a mass of #{@mass}, and #{@number_of_moons} moons." + end +end diff --git a/solar-system.rb b/solar-system.rb new file mode 100644 index 00000000..65adf2c6 --- /dev/null +++ b/solar-system.rb @@ -0,0 +1,20 @@ +class SolarSystem + + attr_accessor :name, :diameter, :mass, :moons + + def initialize(solarsystemname, size) + @solarsystemname = solarsystemname + @size = size + @planets = [] + @array_of_planets = [] + end + + def add_new_planet(planet) + @planets.push(planet) + end + + def add_planets(planet_hash) + @planets.each do |plnt| + @array_of_planets.push(plnt) + end +end