Created
October 17, 2014 07:32
-
-
Save ssaunier/f95ac9e983032bcbe396 to your computer and use it in GitHub Desktop.
cat.rb
This file contains 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 Cat | |
def initialize(name, color) | |
@name = name | |
@color = color | |
@alive = true | |
@color_history = [ color ] | |
end | |
attr_reader :name, :color, :color_history | |
def dye(new_color) | |
@color = new_color | |
@color_history << @color | |
end | |
def meow | |
puts "Meow!" if alive? | |
end | |
def die! | |
@alive = false | |
end | |
def alive? | |
@alive | |
end | |
# METHODE DE CLASSE | |
def self.category | |
"Felin" | |
end | |
attr_writer :color | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment