-
-
Save tefanga/1925b023cef3ea8093ebb1b9a354d67e to your computer and use it in GitHub Desktop.
fito y abuela
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
# Instructions: Declare an objet "AbuelaClotilde" (grandma name) -> Done.. | |
# that understand a messeage... "alimentar_nieto" (feed_grandson)-> Done... | |
# and make him eat("comer") twice, first with 2000 calories then with 1000 calories -> Done... | |
# grandma("AbuelaClotilde") has to have a setter "nieto=(un_nieto)" that lets you configure her grandson("Fito") -> Done.. | |
# AbuelaClotilde grandmother of Fito | |
# Fito = grandson of AbuelaClotilde | |
# @felicidad = happiness value | |
# @peso = weigth | |
# comer = eat | |
# calorias = calories | |
# error messege : AbuelaClotilde should not initialize by default her grandson | |
# expected Exception but nothing was raised | |
module Fito | |
@felicidad = 100 | |
def self.comer(calorias) | |
@peso += calorias * 0.001 | |
end | |
def self.felicidad | |
@felicidad | |
end | |
end | |
module AbuelaClotilde | |
@nieto = | |
def self.alimentar_nieto | |
Fito.comer(3000) | |
end | |
def self.nieto=(un_nieto) | |
@nieto = un_nieto | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment