Created
May 31, 2011 10:35
-
-
Save fuse/1000283 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 Animal | |
attr_accessor :name, :age, :weight | |
def initialize(name, weight, age) | |
@name = name | |
@weight = weight | |
@age = age | |
end | |
def to_s | |
"I'm #{name}, I have #{age} years and I weigh #{weight} KG." | |
end | |
def older?(animal) | |
age > animal.age | |
end | |
def bigger?(animal) | |
weight > animal.weight | |
end | |
protected :age | |
private :weight | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment