Advertisement
AntonioVillanueva

Ejercicio Python Clases 9-1. pag 166 Python Crash Cours

Jan 22nd, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. #!/usr/bin/env pytho
  2. """
  3. 9-1. pag 166 Restaurante: Hacer una clase llamada Restaurante. El método __init __ () para
  4. El restaurante debe almacenar dos atributos: un nombre_restaurante y un tipo_cocina
  5. Haga un método llamado describe_restaurant () que imprima estas dos piezas de
  6. información, y un método llamado open_restaurant () que imprime un mensaje
  7. indicando que el restaurante está abierto.
  8. Haz una instancia llamada restaurante de tu clase. Imprimir los dos atributos
  9. Butes individualmente, y luego llamar a ambos métodos.
  10. """
  11.  
  12. class Restaurante():
  13.  
  14.     def __init__(self,nombre_restaurante,tipo_cocina):
  15.         """Constructor ... Inicializa variables """
  16.         self.nombre_restaurante = nombre_restaurante
  17.         self.tipo_cocina=tipo_cocina
  18.        
  19.     def describe_restaurante(self):
  20.         print("\nNombre :" + self.nombre_restaurante.title() + " , tipo de cocina " + self.tipo_cocina.title())
  21.        
  22.     def open_restaurante(self):
  23.         print ("El restaurante "+self.nombre_restaurante+" , esta abierto")
  24.        
  25. """ Creacion de instancias de la clase Restaurante """
  26. restaurante_A=Restaurante("cedre","francesa")
  27. restaurante_B=Restaurante("asian bowl","china")
  28. restaurante_C=Restaurante("zen","japonesa")
  29.  
  30. """ Utilizacion de los metodos de clase en las instancias """
  31. restaurante_A.describe_restaurante()
  32. restaurante_A.open_restaurante()
  33.  
  34. restaurante_B.describe_restaurante()
  35. restaurante_B.open_restaurante()
  36.  
  37. restaurante_C.describe_restaurante()
  38. restaurante_C.open_restaurante()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement