forked from AdaGold/solar-system
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathplanet.rb
More file actions
20 lines (18 loc) · 729 Bytes
/
planet.rb
File metadata and controls
20 lines (18 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# class that creates instances of planets
class Planet
attr_accessor :name, :color, :mass_kg, :distance_from_sun_km, :fun_fact
# constructor that initializes a name, color, mass (kg), distance from the sun (km), and fun fact
# about each instance of a planet
def initialize(name, color, mass_kg, distance_from_sun_km, fun_fact)
@name = name
@color = color
@mass_kg = mass_kg
@distance_from_sun_km = distance_from_sun_km
@fun_fact = fun_fact
end
# method that prints out a summary of a planet instance
def summary
return "#{@name} is a #{@color} planet with a mass of #{@mass_kg} kg and is #{@distance_from_sun_km} " \
"km from the sun! DID YOU KNOW: #{@fun_fact}?!?!"
end
end