Skip to content
Open
Show file tree
Hide file tree
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 Planets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Planet
Copy link
Author

Choose a reason for hiding this comment

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

in line comment

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
32 changes: 32 additions & 0 deletions SolarPlanetProgram.rb
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions SolarSystem.rb
Original file line number Diff line number Diff line change
@@ -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