Advertisement
hackloper775

Mascotas2

Apr 17th, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import random
  4.  
  5. mascota1 = str(input("Como se llama tu mascota: "))
  6. mascota2 = str(input("Como se llama tu otra mascota: "))
  7. def ambre():
  8.     hambre = random.randint(0,1)
  9.     return hambre
  10. def limpiesa():
  11.     limpieza = random.randint(0,1)
  12.     return limpieza
  13.  
  14. class Mascota(object):
  15.     def __init__(self,nombre,hambre,limpio):
  16.         self.nombre = nombre
  17.         self.limpio = limpio
  18.         self.hambre = hambre
  19.     def tiene_hambre(self):
  20.         if self.hambre == True:
  21.             print ("%s tiene hambre" %(self.nombre))
  22.         else:
  23.             print ("No tiene hambre %s" %(self.nombre))    
  24.     def limpiar(self):
  25.         if self.limpio == True:
  26.             print ("%s necesita limpieza" %(self.nombre))
  27.         else:
  28.             print ("Todo limpio con %s" %(self.nombre))
  29.  
  30. animal1 = Mascota(mascota1,ambre(),limpiesa())
  31. animal1.limpiar()
  32. animal2 = Mascota(mascota2,ambre(),limpiesa())
  33. animal2.tiene_hambre()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement