-
-
Save parzibyte/3d918ec780092f514660a532ca95fe4a 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 Tamagotchi: | |
def __init__(self, nombre): | |
genero = random.choice(["Masculino", "Femenino"]) | |
print("Tu Tamagotchi es " + genero) | |
self.genero = genero | |
self.nombre = nombre | |
self.hambre = 10 | |
self.felicidad = 10 | |
self.salud = 0 | |
def evento(self, accion): | |
self.hambre -= 1 | |
self.felicidad -= 1 | |
if accion == "alimentar": | |
self.alimentar() | |
elif accion == "jugar": | |
self.jugar() | |
def alimentar(self): | |
print("Has alimentado a " + self.nombre) | |
self.hambre += 2 | |
if self.hambre > 10: | |
# Sobrealimentado | |
self.salud += 2 | |
pass | |
def jugar(self): | |
print("Juegas con " + self.nombre) | |
self.felicidad += 3 | |
# Evitar sobrepasar | |
if self.felicidad > 10: | |
self.felicidad = 10 | |
def muere(self): | |
if self.salud >= 10 or self.felicidad <= 0 or self.hambre <= 0: | |
return True | |
else: | |
return False | |
def imprimir_estado(self): | |
print("Hambre: " + str(self.hambre)) | |
print("Felicidad: " + str(self.felicidad)) | |
print("Salud: " + str(self.salud)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment