Created
September 4, 2018 19:12
-
-
Save sevperez/b7e01df05360086a8d58ab3b0cfd6e81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Element | |
attr_accessor :name, :symbol, :number | |
def initialize(name, symbol, number) | |
self.name = name | |
self.symbol = symbol | |
self.number = number | |
end | |
def describe | |
puts "#{self.name} (#{self.symbol}) has atomic number #{self.number}." | |
end | |
end | |
class NobleGas < Element | |
attr_accessor :category, :type, :reactivity | |
def initialize(name, symbol, number) | |
super(name, symbol, number) | |
self.category = "gas" | |
self.type = "noble gas" | |
self.reactivity = "low" | |
end | |
def describe | |
puts "#{self.name} (#{self.symbol}; #{self.number}) is a #{self.category} " + | |
"of type #{self.type}. It has #{self.reactivity} reactivity." | |
end | |
end | |
argon = NobleGas.new("Argon", "Ar", 18) | |
argon.describe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment