예제 #1
0
    def exe(self):
        listaElectrodomesticos = []

        listaElectrodomesticos.append(Electrodomestico(200, 60, 'C', "Verde"))
        listaElectrodomesticos.append(Lavadora(150, 30))
        listaElectrodomesticos.append(
            Television(500, 80, 'E', "negro", 42, False))
        listaElectrodomesticos.append(Electrodomestico())
        listaElectrodomesticos.append(Electrodomestico(600, 20, 'D', "gris"))
        listaElectrodomesticos.append(Lavadora(300, 40, 'Z', "blanco", 40))
        listaElectrodomesticos.append(Television(250, 70))
        listaElectrodomesticos.append(Lavadora(400, 100, 'A', "verde", 15))
        listaElectrodomesticos.append(
            Television(200, 60, 'C', "naranja", 30, True))
        listaElectrodomesticos.append(Electrodomestico(50, 10))

        sumaElectrodomesticos = 0
        sumaTelevisiones = 0
        sumaLavadoras = 0

        for i in listaElectrodomesticos:
            if (isinstance(i, Electrodomestico)):
                sumaElectrodomesticos += i.precioFinal()
            if (isinstance(i, Lavadora)):
                sumaLavadoras += i.precioFinal()
            if (isinstance(i, Television)):
                sumaTelevisiones += i.precioFinal()

        print("La suma del precio de los electrodomesticos es de " +
              str(sumaElectrodomesticos))
        print("La suma del precio de las lavadoras es de " +
              str(sumaLavadoras))
        print("La suma del precio de las televisiones es de " +
              str(sumaTelevisiones))
        print(str(Television(200, 60, 'C', "naranja", 30, True).precioFinal()))
예제 #2
0
def cargar_televisiones():
    x = Television('Sony', 'Vaio', 'Gris', 30, 60, 40)
    televisiones.append(x)
    x = Television('Toshiba', 'L621U', 'Negra', 35, 65, 35)
    televisiones.append(x)
    x = Television('Panasonic', 'TC-49ES600', 'Gris', 40, 60, 40)
    televisiones.append(x)
예제 #3
0
    def exe(self):
        listaElec = []
        listaElec.append(Electrodomestico(400, 'Amarillo', 'A', 30))
        listaElec.append(Lavadora(250, 'Blanco', 'F', 55))
        listaElec.append(Television())
        listaElec.append(Lavadora())
        listaElec.append(Electrodomestico())
        listaElec.append(Television())
        listaElec.append(Lavadora())
        listaElec.append(Electrodomestico())
        listaElec.append(Electrodomestico())
        listaElec.append(Television())

        FinalElec = 0
        FinalLava = 0
        FinalTele = 0

        for i in listaElec:
            if (isinstance(i, Electrodomestico)):
                FinalElec += i.precioFinal()
            if (isinstance(i, Lavadora)):
                FinalLava += i.precioFinal()
            if (isinstance(i, Television)):
                FinalTele += i.precioFinal()

        print("Los electrodomesticos tienen un precio total de " +
              str(FinalElec))
        print("Las Lavadoras tienen un precio total de " + str(FinalLava))
        print("Las Televisiones tienen un precio total de " + str(FinalTele))
예제 #4
0
  def __init__(self):
    """Creates a new DeluxeTV instance.

    The power is initially off, yet when turned on the TV is tuned to channel 2
    with a volume level of 5. The set of favorite channels is initially empty.
    """
    Television.__init__(self)                    # parent constructor
    self._favorites = []
예제 #5
0
  def __init__(self):
    """
    Creates a new Television instance.

    The power is initially off.  Upon the first time the TV is turned on,
    it will be set to channel 2, and a volume level of 5.

    The television maintains a list of favorite channels, initially empty.
    """
    Television.__init__(self)                     # parent constructor
    self._favorites = SortedSet()
예제 #6
0
class DeluxeTV(Television):
    """TV that maintains a set of favorite channels"""
    def __init__(self):
        """call the base class Television to initialize the DeluxeTV also"""
        Television.__init__(self)
        self._favorites = []

    def addToFavorites(self):
        """Add current channel to favorites"""
        if self._powerOn and self._channel not in self._favorites:
            self._favorites.append(self._channel)

    def removeFromFavorites(self):
        """Remove current channel from favorites"""
        if self._powerOn and self._channel in self._favorites:
            self._favorites.remove(self._channel)

    def jumpToFavorite(self):
        """Jumps to next higher channel in favorites. If none higher then it wraps to lower and no favorites remains the same"""
        if self._powerOn and len(self._favorites) > 0:
            closest = max(self._favorites)
            if closest <= self._channel:
                closest = min(self._favorites)
            else:
                for option in self._favorites:
                    if self._channel < option < closest:
                        closest = option
            self.setChannel(closest)
            return closest

    unitTV = Television()
    unitTV.togglePower()

    print "Resulting state: ", unitTV
    unitTV2 = Television()
    unitTV2.togglePower()

    print "Resulting state: ", unitTV2

    MyTV = Television()
    MyTV.togglePower()
    print "My TV Channel Is 66 "
    print "My TV Volume Is 7 "
    print "My deluxTV Channel Is 77 "
    print "My deluxTV Volume Is 8 "
예제 #7
0
    def main():
        lista_refris = []
        ref = Refrigerador('rojo', '10,000', 'ref009', '28-04-2017', 'México',
                           'GE', '10', False, 0)
        lista_refris.append(ref)
        ref = Refrigerador('Blanco', '8,000', 'ref1010', '10-08-16', 'México',
                           'IEM', '7', False, 0)
        lista_refris.append(ref)
        ref = Refrigerador('Negro', '7,000', 're222', '01-01-11', 'México',
                           'HI', '9', True, 0)
        lista_refris.append(ref)

        for i in lista_refris:
            i.imprime_especificaciones()

        #ref.menu_temperatura()
        #print('Nueva tempreratura: {} grados'.format(ref.get_temperatura()))

        lista_tv = []
        tv = Television('negro', '10,000', 'tv0012', '08-06-13', 'México',
                        'SAMSUNG', True, True)
        lista_tv.append(tv)
        tv = Television('blanco', '4,000', 'tv0111', '17-04-11', 'México',
                        'PHILLIPS', True, True)
        lista_tv.append(tv)
        tv = Television('gris', '2,000', 'tvSSSS', '3-02-12', 'México', 'AVIO',
                        True, True)
        lista_tv.append(tv)

        for i in lista_tv:
            i.imprimeAtributos()
            print(i.datos_tv())
        lista_lavadoras = []
        lavadora = Lavadora('Blanco', '10,000', 'lvk9090', '09-05-09',
                            'México', 'Whirlpool', 8, 10)
        lista_lavadoras.append(lavadora)
        lavadora = Lavadora('blanco', '7100', 'lvv001', '01-02-12', 'México',
                            'Zenith', 10, 7)
        lista_lavadoras.append(lavadora)
        lavadora = Lavadora('blanco', '7100', 'lvv001', '30-07-13', 'México',
                            'Elías', 18, 11)
        lista_lavadoras.append(lavadora)
        for i in lista_lavadoras:
            i.datos_lavadora()
예제 #8
0
def start():
    tv = Television()
    frigeratory = Refrigeratory()
    air = AirConditioner()

    haier = Haier()

    haier.setAppliance(tv)
    haier.produce()

    haier.setAppliance(frigeratory)
    haier.produce()

    haier.setAppliance(air)
    haier.produce()

    print

    tcl = TCL()

    tcl.setAppliance(tv)
    tcl.produce()

    tcl.setAppliance(frigeratory)
    tcl.produce()

    tcl.setAppliance(air)
    tcl.produce()

    print

    hisense = Hisense()

    hisense.setAppliance(tv)
    hisense.produce()

    hisense.setAppliance(frigeratory)
    hisense.produce()

    hisense.setAppliance(air)
    hisense.produce()
예제 #9
0
electros = ()
electros = list(electros)

# Electrodomesticos
electros.insert(-1, Electrodomestico(consumo="A", peso=15))
electros.insert(-1, Electrodomestico(consumo="A", peso=30))
electros.insert(-1, Electrodomestico(consumo="A", peso=60))
electros.insert(-1, Electrodomestico(consumo="A", peso=90))

# Lavadoras
electros.insert(-1, Lavadora(consumo="E", peso=50, carga=30))
electros.insert(-1, Lavadora(consumo="A", peso=50, carga=60))

# Televisiones
electros.insert(-1, Television(peso=20, resolucion=30))
electros.insert(-1, Television(peso=20, resolucion=50))

tv, lava, electro = 0, 0, 0
i = 0
for ele in electros:
    i += 1
    ele.precioFinal()
    # print(ele.precioBase)

    if isinstance(ele, Television):
        tv += ele.precioBase
    elif isinstance(ele, Lavadora):
        lava += ele.precioBase
    else:
        electro += ele.precioBase
예제 #10
0
 def __init__(self):
     """call the base class Television to initialize the DeluxeTV also"""
     Television.__init__(self)
     self._favorites = []