class Tama::Animal

Classe animal dont herite Virtualanimal. Elle contient toutes la base du tamagotchi

Attributes

DateBirth[R]
Date_of_death[R]
health[R]
mental[R]

Public Class Methods

new() click to toggle source

Construteur principal

# File lib/tama/animal_class.rb, line 16
def initialize
    @health=$TAMA_HEALTH
    @mental=$TAMA_MENTAL
    @@nbreAnimal+=1
    puts "Creation de l'animal \n"
    @DateBirth=Chronic.parse("now")
    @Date_of_death=Chronic.parse("#{$TIME_OF_LIFE} minutes from now")
end

Public Instance Methods

DieOfTama() click to toggle source
# File lib/tama/animal_class.rb, line 73
def DieOfTama
    ObjectSpace.garbage_collect
end
clean() click to toggle source

Fonction nettoyer le tama - le faire prendre un bain

# File lib/tama/animal_class.rb, line 49
def clean
    puts"Vous nettoyez votre animal \n"
    @mental +=10
    @health +=30
    return 4
end
cure() click to toggle source

Fonction soigner du tama

# File lib/tama/animal_class.rb, line 40
def cure
    puts"Vous soignez votre animal \n"
    @mental +=30
    @health +=60
    return 3
end
feed() click to toggle source

Fonction manger du tama

# File lib/tama/animal_class.rb, line 26
def feed
    puts"Votre animal se nourrit \n"
    @health += 30
    return 1
end
isAlive?() click to toggle source

Fonction qui permet de savoir si le tama est vivant ou mort

# File lib/tama/animal_class.rb, line 59
def isAlive?
    time_to_die=@Date_of_death
    actual_time=Chronic.parse("now")
        if actual_time > time_to_die 
            puts "Votre tama est mort"
            return false
        else
            puts "Votre tama est vivant"
            return true
        end
end
teach() click to toggle source

Fonction enseigner du tama

# File lib/tama/animal_class.rb, line 33
def teach
    puts"Votre animal apprend quelque chose \n"
    @mental += 10
    return 2
end