diff --git a/Planets.rb b/Planets.rb new file mode 100644 index 00000000..112c4960 --- /dev/null +++ b/Planets.rb @@ -0,0 +1,26 @@ +class Planet + attr_accessor :name, :atmosphere, :population + + def initialize(planet_hash) + @name = planet_hash[:name] + @atmosphere = planet_hash[:atmosphere] + @population = planet_hash[:population] + @planets = [] + end + + def say_hello(name="Alien") + puts "welcome #{name}!" + end + + def print_out + puts "This is planet #{@name}, it's atmosphere is composed of #{@atmosphere}. It's population make up is #{@population}." + end + + def add_planet(planet) + @planets.push(planet) + end + + def add_planet_array(planet_array) + planet_array.each do |planet| + @planets.push(planet) +end diff --git a/SolarPlanetProgram.rb b/SolarPlanetProgram.rb new file mode 100644 index 00000000..21c2f5fa --- /dev/null +++ b/SolarPlanetProgram.rb @@ -0,0 +1,32 @@ +require "./Planets" +require "./SolarSystem" + +eclipse_hash = { + name: "Eclipse", + atmosphere: "eggs", + population: "eliptons" +} +eclipse= Planet.new(eclipse_hash) + +solarium_hash = { + name: "Solarium", + atmosphere: "bubble gum", + population: "solarians" +} +solarium= Planet.new(eclipse_hash) + +barium_hash = { + name: "Barium", + atmosphere: "cotton candy", + population: "solarians" +} +barium= Planet.new(barium_hash) + +solarsystem=SolarSystem.new("Andromeda") +solarsystem.add_planet(planet) + +eclipse.say_hello +eclipse.say_hello("bob") + +solarsystem.print_out +solarsystem.galaxy diff --git a/SolarSystem.rb b/SolarSystem.rb new file mode 100644 index 00000000..8c970fb1 --- /dev/null +++ b/SolarSystem.rb @@ -0,0 +1,33 @@ +class SolarSystem + attr_accessor :name, :galaxy, :star + def initialize(info_hash) + @name = info_hash[:name] + @galaxy = info_hash[:galaxy] + @star = info_hash[:star] + end + +def print_out + puts "This is planet #{@name}, in the galaxy #{@galaxy}, in the star #{@star}, with the planets #{@planets}" +end +end + +starfox_hash = { + name: "starfox", + galaxy: "Loop", + star: "Scorpio" +} + +starbear_hash = { + name: "starbear", + galaxy: "Black Hole", + star: "Pisces" +} + +starcat_hash = { + name: "starcat" + galaxy: "Worm", + star: "Aquarius" +} + +s = SolarSystem.new(starfox) +puts s