Skip to content
Open
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
33 changes: 33 additions & 0 deletions solar-system.rb
Original file line number Diff line number Diff line change
@@ -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