Skip to content

Instantly share code, notes, and snippets.

@guillaumebihet
Created October 1, 2017 15:30
Show Gist options
  • Save guillaumebihet/31ef1f02e071ebda04c635b0b0b1bc34 to your computer and use it in GitHub Desktop.
Save guillaumebihet/31ef1f02e071ebda04c635b0b0b1bc34 to your computer and use it in GitHub Desktop.
Quizz 3 - build a class
class Star
attr_accessor :name, :spectral_class, :type
def initialize(name, spectral_class, type)
@name = name
@spectral_class = spectral_class
@type = type
end
def describe
puts "#{@name} is a #{@type}, its spectral class is #{@spectral_class}"
end
end
Arcturus = Star.new("Arcturus", "K", "Red Giant")
Proxima_centauri = Star.new("Proxima Centauri", "M", "Red Dwarf")
puts Arcturus.describe
puts Proxima_centauri.describe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment