Created
March 6, 2013 04:23
-
-
Save gabrielslau/5096684 to your computer and use it in GitHub Desktop.
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 Cachorro | |
attr_accessor :raca, :nome, :idade | |
def aniversario() | |
@idade = self.idade + 1 | |
end | |
def latir() | |
latido = "Au" | |
if(self.idade > 0 and self.idade <= 5) then | |
# Do nothing | |
elsif(self.idade > 5 and self.idade <= 10) then | |
latido = latido * 2 | |
elsif(self.idade > 10) then | |
latido = latido * 3 | |
end | |
return latido | |
end | |
end | |
dog = Cachorro.new | |
dog.raca = "Pastor Alemao" | |
dog.nome = "Laika" | |
dog.idade = 5 | |
puts dog.latir | |
dog.aniversario | |
puts dog.latir | |
dog.aniversario | |
dog.aniversario | |
dog.aniversario | |
dog.aniversario | |
dog.aniversario | |
puts dog.latir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment