コード例 #1
0
    def setUp(self):
        self.billete100 = Billete_100(100, "Pesos")
        self.billete200 = Billete_200(200, "Pesos")
        self.billete500 = Billete_500(500, "Pesos")
        self.billete1000 = Billete_1000(1000, "Pesos")

        self.cajero = Cajero_automatico()

        self.lista1 = []
        for i in range(10):
            self.lista1.append(self.billete1000)

        self.lista2 = []
        for i in range(10):
            self.lista2.append(self.billete1000)
        for i in range(20):
            self.lista2.append(self.billete500)

        self.lista3 = []
        for i in range(10):
            self.lista3.append(self.billete1000)
        for i in range(20):
            self.lista3.append(self.billete500)
        for i in range(15):
            self.lista3.append(self.billete200)
コード例 #2
0
 def setUp(self):
     self.cargo = Cajero_automatico()
     self.lista = []
     for i in range(10):
         self.lista.append(mil)
         self.lista.append(quinientos)
         self.lista.append(quinientos)
     self.cargo.agregar_dinero(self.lista)
コード例 #3
0
def main():

    cien = billete_100(100, 'pesos', '$100')
    doscientos = billete_200(200, 'pesos', '$200')
    quinientos = billete_500(500, 'pesos', '$500')
    mil = billete_1000(1000, 'pesos', '$1000')

    c = Cajero_automatico()
    c.agregar_dinero([
        cien, doscientos, doscientos, mil, doscientos, quinientos, mil, mil,
        mil, cien, cien, cien, cien, cien, cien, cien, cien, mil, quinientos,
        quinientos, quinientos, doscientos, cien, cien, cien, quinientos, cien
    ])
    print(c.contar_dinero())

    c.extraer_dinero(5000, 20)
    print(c.extraer_dinero_cambio())
    c.final()
コード例 #4
0
class Test_Cajero_1(unittest.TestCase):
    def setUp(self):
        self.lastcargo = Cajero_automatico()
        self.lista = []
        for i in range(10):
            self.lista.append(mil)
            self.lista.append(quinientos)
            self.lista.append(quinientos)
            self.lista.append(doscientos)
        for i in range(5):
            self.lista.append(doscientos)
        self.lastcargo.agregar_dinero(self.lista)


#Test3:

    def test_a(self):

        conteo = self.lastcargo.contar_dinero()
        self.assertEqual(
            conteo, 'parcial: $10000\n' + '10 billetes de $1000\n' +
            'parcial: $10000\n' + '20 billetes de $500\n' +
            'parcial: $3000\n' + '15 billetes de $200\n' + '\ntotal: $23000')

    def test_b(self):

        num = self.lastcargo.extraer_dinero(5000, 0)
        self.assertEqual(num, '5 billetes de $1000\n')

    def test_c(self):

        billetes = self.lastcargo.extraer_dinero(12000, 0)
        self.assertEqual(billetes,
                         '10 billetes de $1000\n' + '4 billetes de $500\n')

    def test_d(self):

        error = self.lastcargo.extraer_dinero(12100, 0)
        self.assertEqual(
            error,
            'Error. No hay una combinación de billetes que nos permita extraer ese monto'
        )

    def test_e(self):

        self.lastcargo.extraer_dinero(7000, 10)
        billetes2 = self.lastcargo.extraer_dinero_cambio()
        self.assertEqual(billetes2,
                         '5 billetes de $200\n' + '6 billetes de $1000\n')
コード例 #5
0
class Test_Cajero_1(unittest.TestCase):

    def setUp(self):
        self.ingreso = Cajero_automatico()
        self.lista=[]
        for x in range(10):
            self.lista.append(mil)
        self.ingreso.agregar_dinero(self.lista)
                            

#TEST 1:
    def test_a(self):
        
        conteo = self.ingreso.contar_dinero()
        self.assertEqual(conteo, 'parcial: $10000\n' + '10 billetes de $1000\n' + '\ntotal: $10000')
    
    def test_b(self):
        
        num = self.ingreso.extraer_dinero(5000,0)
        self.assertEqual(num, '5 billetes de $1000\n')
    
    def test_c(self):    
        
        error1 = self.ingreso.extraer_dinero(12000,0)
        self.assertEqual(error1, 'Error. Quiero sacar mas dinero de lo que puedo')
    
    def test_d(self):    
       
        error2 = self.ingreso.extraer_dinero(5520,0)
        self.assertEqual(error2, 'Error. El monto es incorrecto')
コード例 #6
0
 def __init__(self):
     self.cajero = Cajero_automatico()  # objeto cajero
     self.lista_billetes = []
コード例 #7
0
class Api():
    def __init__(self):
        self.cajero = Cajero_automatico()  # objeto cajero
        self.lista_billetes = []

    def ejecutar(self):
        os.system("reset")
        print("CAJERO AUTOMATICO")
        flag = True
        while flag == True:
            menu = self.menu()
            if (menu == 1):
                os.system("clear clc")
                self.reconocer_billetes()
            elif (menu == 2):
                os.system("clear clc")
                print("\nVaciando cajero...")
                self.cajero.vaciar_cajero()
            elif (menu == 3):
                os.system("clear clc")
                while True:
                    try:
                        monto = int(input("\nIngrese el monto a extraer: "))
                        if (monto % 100 != 0):
                            raise ValueError  #si el monto no es multiplo de 100
                        else:
                            entrega = self.cajero.extraer_dinero(monto)
                            total = 0
                            if (type(entrega) is list):
                                print("\nBilletes entregados: ")
                                for i in range(len(entrega)):
                                    print(entrega[i].denominacion)
                                    total += entrega[i].denominacion
                                print("\nTotal entregado: ${}".format(total))
                                break
                            else:
                                break
                    except ValueError:
                        print("\n**ERROR**Debe extraer un multiplo de 100")
            elif (menu == 4):
                os.system("clear clc")
                while True:
                    try:
                        monto = int(input("\nIngrese el monto a extraer: "))
                        if (monto % 100 != 0):
                            raise ValueError  # si el monto no es multiplo de 100
                        else:
                            while True:
                                try:
                                    porcentaje = int(
                                        input(
                                            "\nIngrese el porcentaje de cambio deseado: "
                                        ))
                                    if porcentaje < 0 or porcentaje > 100:
                                        raise ValueError
                                    else:
                                        break
                                except ValueError:
                                    print(
                                        "\n***ERROR*** Debe introducir un porcentaje entre 0 y 100"
                                    )
                            entrega, cambio = self.cajero.extraer_dinero_cambio(
                                monto, porcentaje)
                            total = 0
                            total_cambio = 0
                            if (type(entrega) is list):
                                print("\nBilletes entregados: ")
                                if (type(cambio) is list):
                                    for i in range(len(cambio)):
                                        print(cambio[i].denominacion)
                                        total_cambio += cambio[i].denominacion
                                    print("Total cambio entregado: ${}".format(
                                        total_cambio))
                                for i in range(len(entrega)):
                                    print(entrega[i].denominacion)
                                    total += entrega[i].denominacion
                                print(
                                    "Total resto entregado: ${}".format(total))
                                print("\nTotal: ${}".format(total +
                                                            total_cambio))
                                break
                            else:
                                break
                    except ValueError:
                        print("\n**ERROR**Debe extraer un multiplo de 100")
            elif (menu == 5):
                os.system("clear clc")
                parcial, total = self.cajero.contar_dinero()
                print("Montos Parciales:")
                for i in range(len(parcial)):
                    print("${}".format(parcial[i]))
                print("Monto Total: ${}".format(total))
            else:
                os.system("clear clc")
                print("\nCerrando Sesion...")
                flag = False
            print()

    def cargar_cajero(self):
        if (len(self.lista_billetes) > 0):
            self.cajero.agregar_dinero(self.lista_billetes)
        else:
            print("\n**Error al cargar cajero** No se ha ingresado dinero")
        self.lista_billetes.clear()

    def reconocer_billetes(self):
        tipo = "Pesos"
        eleccion = int(
            input("""
        Ingrese la cantidad de billetes de 100: """))
        for i in range(eleccion):
            billete = Billete_100(100, tipo)
            self.lista_billetes.append(billete)
        eleccion = int(
            input("""
        Ingrese la cantidad de billetes de 200: """))
        for i in range(eleccion):
            billete = Billete_200(200, tipo)
            self.lista_billetes.append(billete)
        eleccion = int(
            input("""
        Ingrese la cantidad de billetes de 500: """))
        for i in range(eleccion):
            billete = Billete_500(500, tipo)
            self.lista_billetes.append(billete)
        eleccion = int(
            input("""
        Ingrese la cantidad de billetes de 1000: """))
        for i in range(eleccion):
            billete = Billete_1000(1000, tipo)
            self.lista_billetes.append(billete)

        self.cargar_cajero()

    def menu(self):
        while True:
            try:
                eleccion = int(
                    input("""
                Ingrese que desea hacer:
                1- Cargar cajero
                2- Vaciar cajero
                3- Extraer dinero
                4- Extraer dinero con cambio
                5- Contar dinero cajero

                0- Salir
                                    
                Eleccion: """))
                if (eleccion != 1 and eleccion != 2 and eleccion != 3
                        and eleccion != 4 and eleccion != 5 and eleccion != 0):
                    raise ValueError
                else:
                    break
            except ValueError:
                os.system("clear clc")
                print("\n***ERROR*** Introduzca una opcion válida")

        return eleccion
コード例 #8
0
class TestCajero(unittest.TestCase):
    os.system("reset")

    def setUp(self):
        self.billete100 = Billete_100(100, "Pesos")
        self.billete200 = Billete_200(200, "Pesos")
        self.billete500 = Billete_500(500, "Pesos")
        self.billete1000 = Billete_1000(1000, "Pesos")

        self.cajero = Cajero_automatico()

        self.lista1 = []
        for i in range(10):
            self.lista1.append(self.billete1000)

        self.lista2 = []
        for i in range(10):
            self.lista2.append(self.billete1000)
        for i in range(20):
            self.lista2.append(self.billete500)

        self.lista3 = []
        for i in range(10):
            self.lista3.append(self.billete1000)
        for i in range(20):
            self.lista3.append(self.billete500)
        for i in range(15):
            self.lista3.append(self.billete200)

    #Set de pruebas 1
    def test1_contardinero(self):
        self.cajero.agregar_dinero(self.lista1)
        self.assertEqual(self.cajero.contar_dinero(),
                         ([0, 0, 0, 10000], 10000))
        self.cajero.vaciar_cajero()

    def test1_extraerdinero(self):
        self.cajero.agregar_dinero(self.lista1)
        b1000 = self.billete1000
        lista_entrega = []
        for i in range(5):
            lista_entrega.append(b1000)
        self.assertEqual(self.cajero.extraer_dinero(5000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test1_extraerdinero2(self):
        self.cajero.agregar_dinero(self.lista1)
        with self.assertRaises(dineroInsuficiente):
            self.cajero.extraer_dinero(12000)
        self.cajero.vaciar_cajero()

    def test1_extraerdinero3(self):
        self.cajero.agregar_dinero(self.lista1)
        with self.assertRaises(multiploError):
            self.cajero.extraer_dinero(5520)
        self.cajero.vaciar_cajero()

    #Set de pruebas 2
    def test2_contardinero(self):
        self.cajero.agregar_dinero(self.lista2)
        self.assertEqual(self.cajero.contar_dinero(),
                         ([0, 0, 10000, 10000], 20000))
        self.cajero.vaciar_cajero()

    def test2_extraerdinero(self):
        self.cajero.agregar_dinero(self.lista2)
        lista_entrega = []
        for i in range(5):
            lista_entrega.append(self.billete1000)
        self.assertEqual(self.cajero.extraer_dinero(5000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test2_extraerdinero2(self):
        self.cajero.agregar_dinero(self.lista2)
        lista_entrega = []
        for i in range(10):
            lista_entrega.append(self.billete1000)
        for i in range(4):
            lista_entrega.append(self.billete500)
        self.assertEqual(self.cajero.extraer_dinero(12000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test2_extraerdinero3(self):
        self.cajero.agregar_dinero(self.lista2)
        with self.assertRaises(imposibleExtraer):
            self.cajero.extraer_dinero(12100)
        self.cajero.vaciar_cajero()

    def test2_extraerdinero_cambio(self):
        self.cajero.agregar_dinero(self.lista2)
        lista_entrega = []
        lista_entrega_cambio = []
        for i in range(2):
            lista_entrega_cambio.append(self.billete500)
        for i in range(6):
            lista_entrega.append(self.billete1000)
        self.assertEqual(self.cajero.extraer_dinero_cambio(7000, 10),
                         (lista_entrega, lista_entrega_cambio))
        self.cajero.vaciar_cajero()

    #Set de prueba 3
    def test3_contardinero(self):
        self.cajero.agregar_dinero(self.lista3)
        self.assertEqual(self.cajero.contar_dinero(),
                         ([0, 3000, 10000, 10000], 23000))
        self.cajero.vaciar_cajero()

    def test3_extraerdinero(self):
        self.cajero.agregar_dinero(self.lista3)
        lista_entrega = []
        for i in range(5):
            lista_entrega.append(self.billete1000)
        self.assertEqual(self.cajero.extraer_dinero(5000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test3_extraerdinero2(self):
        self.cajero.agregar_dinero(self.lista3)
        lista_entrega = []
        for i in range(10):
            lista_entrega.append(self.billete1000)
        for i in range(4):
            lista_entrega.append(self.billete500)
        self.assertEqual(self.cajero.extraer_dinero(12000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test3_extraerdinero3(self):
        self.cajero.agregar_dinero(self.lista3)
        with self.assertRaises(imposibleExtraer):
            self.cajero.extraer_dinero(12100)
        self.cajero.vaciar_cajero()

    def test3_extraerdinero_cambio(self):
        self.cajero.agregar_dinero(self.lista3)
        lista_entrega = []
        lista_entrega_cambio = []
        for i in range(4):
            lista_entrega_cambio.append(self.billete200)
        for i in range(6):
            lista_entrega.append(self.billete1000)
        lista_entrega.append(self.billete200)
        self.assertEqual(self.cajero.extraer_dinero_cambio(7000, 10),
                         (lista_entrega, lista_entrega_cambio))
        self.cajero.vaciar_cajero()

    #set de prueba 4 -> para probar nuevas excepciones incorporadas
    def test4_extraerdinero(self):
        with self.assertRaises(cajeroVacio):
            self.cajero.extraer_dinero(100)

    def test4_extraerdinero1(self):
        with self.assertRaises(extraccionNegativa):
            self.cajero.extraer_dinero(-500)

    def test4_extraerdinero_cambio(self):
        self.cajero.agregar_dinero(self.lista1)
        with self.assertRaises(porcentajeCambio):
            self.cajero.extraer_dinero_cambio(1000, 120)
        self.cajero.vaciar_cajero()

    def test4_extraerdinero_cambio2(self):
        self.cajero.agregar_dinero(self.lista1)
        with self.assertRaises(porcentajeCambio):
            self.cajero.extraer_dinero_cambio(1000, -20)
        self.cajero.vaciar_cajero()
コード例 #9
0
 def setUp(self):
     self.ingreso = Cajero_automatico()
     self.lista=[]
     for x in range(10):
         self.lista.append(mil)
     self.ingreso.agregar_dinero(self.lista)
コード例 #10
0
    persona_DAO = PersonaDao(db)
    actividad_DAO = ActividadDao(db)
    tipo_DAO = Tipo_ActividadDao(db)

    pers1 = Persona("Joaquin", "Hernandez", "Cliente")
    pers2 = Persona("Armando", "Esteban Quito", "Cliente")

    persona_DAO.guardar(pers1)
    persona_DAO.guardar(pers2)

    cargar_dinero = Tipo_Actividad("Deposito", "Ingresar dinero")
    extraer_dinero = Tipo_Actividad("Extraccion", "Extraer dinero")
    tipo_DAO.guardar(cargar_dinero)
    tipo_DAO.guardar(extraer_dinero)

    cajero1 = Cajero_automatico()
    cajero2 = Cajero_automatico()

    #Creo Billetes
    a = Billete100()
    b = Billete200()
    c = Billete500()
    d = Billete1000()
    e = Billete200()
    f = Billete1000()

    dep1 = [a, b, c, d, e, f]  #3000 #Deposito1
    dep2 = [a, a, b, b, c, c, d, d]  #3600 #Deposito2

    agr_bill_1 = cajero1.agregar_billetes(dep1)
    agr_bill_2 = cajero2.agregar_billetes(dep2)
コード例 #11
0
class TestCajero(unittest.TestCase):
    os.system("reset")

    def setUp(self):
        self.billete100 = Billete_100(100, "Pesos")
        self.billete200 = Billete_200(200, "Pesos")
        self.billete500 = Billete_500(500, "Pesos")
        self.billete1000 = Billete_1000(1000, "Pesos")

        self.cajero = Cajero_automatico()

        self.lista1 = []
        for i in range(10):
            self.lista1.append(self.billete1000)

        self.lista2 = []
        for i in range(10):
            self.lista2.append(self.billete1000)
        for i in range(20):
            self.lista2.append(self.billete500)

        self.lista3 = []
        for i in range(10):
            self.lista3.append(self.billete1000)
        for i in range(20):
            self.lista3.append(self.billete500)
        for i in range(15):
            self.lista3.append(self.billete200)

    #Set de pruebas 1
    def test1_contardinero(self):
        self.cajero.agregar_dinero(self.lista1)
        self.assertEqual(self.cajero.contar_dinero(),
                         ([0, 0, 0, 10000], 10000))
        self.cajero.vaciar_cajero()

    def test1_extraerdinero(self):
        self.cajero.agregar_dinero(self.lista1)
        b1000 = self.billete1000
        lista_entrega = []
        for i in range(5):
            lista_entrega.append(b1000)
        self.assertEqual(self.cajero.extraer_dinero(5000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test1_extraerdinero2(self):
        self.cajero.agregar_dinero(self.lista1)
        respuesta = "**ERROR**Cantidad de dinero insuficente en cajero"
        self.assertEqual(self.cajero.extraer_dinero(12000), (respuesta))
        self.cajero.vaciar_cajero()

    #Set de pruebas 2
    def test2_contardinero(self):
        self.cajero.agregar_dinero(self.lista2)
        self.assertEqual(self.cajero.contar_dinero(),
                         ([0, 0, 10000, 10000], 20000))
        self.cajero.vaciar_cajero()

    def test2_extraerdinero(self):
        self.cajero.agregar_dinero(self.lista2)
        lista_entrega = []
        for i in range(5):
            lista_entrega.append(self.billete1000)
        self.assertEqual(self.cajero.extraer_dinero(5000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test2_extraerdinero2(self):
        self.cajero.agregar_dinero(self.lista2)
        lista_entrega = []
        for i in range(10):
            lista_entrega.append(self.billete1000)
        for i in range(4):
            lista_entrega.append(self.billete500)
        self.assertEqual(self.cajero.extraer_dinero(12000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test2_extraerdinero3(self):
        self.cajero.agregar_dinero(self.lista2)
        respuesta = "**ERROR** No se puede entregar la combinacion de billetes necesaria"
        self.assertEqual(self.cajero.extraer_dinero(12100), respuesta)
        self.cajero.vaciar_cajero()

    def test2_extraerdinero_cambio(self):
        self.cajero.agregar_dinero(self.lista2)
        lista_entrega = []
        lista_entrega_cambio = []
        for i in range(2):
            lista_entrega_cambio.append(self.billete500)
        for i in range(6):
            lista_entrega.append(self.billete1000)
        self.assertEqual(self.cajero.extraer_dinero_cambio(7000, 10),
                         (lista_entrega, lista_entrega_cambio))
        self.cajero.vaciar_cajero()

    #Set de prueba 3
    def test3_contardinero(self):
        self.cajero.agregar_dinero(self.lista3)
        self.assertEqual(self.cajero.contar_dinero(),
                         ([0, 3000, 10000, 10000], 23000))
        self.cajero.vaciar_cajero()

    def test3_extraerdinero(self):
        self.cajero.agregar_dinero(self.lista3)
        lista_entrega = []
        for i in range(5):
            lista_entrega.append(self.billete1000)
        self.assertEqual(self.cajero.extraer_dinero(5000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test3_extraerdinero2(self):
        self.cajero.agregar_dinero(self.lista3)
        lista_entrega = []
        for i in range(10):
            lista_entrega.append(self.billete1000)
        for i in range(4):
            lista_entrega.append(self.billete500)
        self.assertEqual(self.cajero.extraer_dinero(12000), lista_entrega)
        self.cajero.vaciar_cajero()

    def test3_extraerdinero3(self):
        self.cajero.agregar_dinero(self.lista3)
        respuesta = "**ERROR** No se puede entregar la combinacion de billetes necesaria"
        self.assertEqual(self.cajero.extraer_dinero(12100), respuesta)
        self.cajero.vaciar_cajero()

    def test3_extraerdinero_cambio(self):
        self.cajero.agregar_dinero(self.lista3)
        lista_entrega = []
        lista_entrega_cambio = []
        for i in range(4):
            lista_entrega_cambio.append(self.billete200)
        for i in range(6):
            lista_entrega.append(self.billete1000)
        lista_entrega.append(self.billete200)
        self.assertEqual(self.cajero.extraer_dinero_cambio(7000, 10),
                         (lista_entrega, lista_entrega_cambio))
        self.cajero.vaciar_cajero()