class Encendedor:
    
    MAX_CAPACITY = 10 # Se define la capacidad máxima del tanque con una variable de clase

    def __init__(self):
        self.combustible_actual = Encendedor.MAX_CAPACITY # Observar como se accede a la variable de clase

    # Retorna por True o False si queda combustible para realizar al menos un encendido.
    def hay_combustible(self):
        return (self.combustible_actual >= 1)
        
    def encender(self):
        if self.hay_combustible():
            print ("Encendedor encendido")
            self.combustible_actual -= 1
        else:
            print ("No hay suficiente combustible para encender")
    
    def apagar(self):
        print("Encendedor apagado")

    def llenar_tanque(self):
        self.combustible_actual = Encendedor.MAX_CAPACITY
        print("Se ha completado la carga")
        

e = Encendedor()
for i in range(11):
    e.encender()
    
e.llenar_tanque()
e2 = Encendedor()
e2.encender()


    
            

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: