Skip to content

Instantly share code, notes, and snippets.

@gabrielslau
Created March 6, 2013 04:23
Show Gist options
  • Save gabrielslau/5096684 to your computer and use it in GitHub Desktop.
Save gabrielslau/5096684 to your computer and use it in GitHub Desktop.
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