コード例 #1
0
ファイル: main.c プロジェクト: Blacknux/more-more-
/** \brief Imprime una serie de informes
 *          1- Imprime nomina ocmpleta
 *          2- solicita desde y hasta e imprime una sublista de empleados por legajo
 *          3 imprime listado por sueldo < o >
 *
 * \param pList ArrayList* array de donde se obtendran los datos
 * \return int
 *
 */
int informes(ArrayList* pList)
{
    int option;
    int from;
    int to;
    int returnAux=-1;
    int order;
    ArrayList* ArrayAux=al_newArrayList();
if(pList!=NULL && ArrayAux!=NULL )
{
    getInt(&option,"\n1-Imprimir Nomina\n2-Imprimir Sub-Nomina\n3-Imprimir listado por sueldo\n4-Salir\nOption:","Error Opcion no valida",1,4);

    switch(option)
    {
    case 1:
        PrintEmployees(pList);
        break;
    case 2:
        if(!getInt(&from,"Ingrese desde que legajo:","Error Legajo mayor a los empleados en nomina...\n",0,pList->size)&&
        getInt(&to,"Ingrese hasta que legajo:","Error Legajo mayor a los empleados en nomina...\n",0,pList->size))
        {
            ArrayAux=al_subList(pList,from-1,to);
            PrintEmployees(ArrayAux);
            al_deleteArrayList(ArrayAux);
        }


        break;
    case 3:
        if(!getInt(&order,"\n1-Mostrar Nomina por sueldo de mayor a menor\n2-Mostrar Nomina por sueldo de menor a mayor\nOption:","Error",1,2))
        {
            switch(order)
            {
            case 1:
                ArrayAux=pList->clone(pList);
                pList->sort(ArrayAux,compareEmployee,0);
                PrintEmployees(ArrayAux);
                pList->deleteArrayList(ArrayAux);
                break;
            case 2:
                ArrayAux=pList->clone(pList);
                pList->sort(ArrayAux,compareEmployee,1);
                PrintEmployees(ArrayAux);
                pList->deleteArrayList(ArrayAux);
                break;

            }
        }
        break;
    case 4:
        break;
    }
    returnAux=0;
}
return returnAux;
}
コード例 #2
0
ファイル: thirdTest.c プロジェクト: Blacknux/ArrayList
void thirdTestCase01(void)
{

    int r;
    ArrayList* list=NULL;

    r = al_deleteArrayList(list);
    utest_assertEqualsIntMsg(r,-1,"Error in return value <deleteArrayList> if array pointer is NULL, the correct value to return is: (-1)");


}
コード例 #3
0
ファイル: lib.c プロジェクト: GermanMoltoni/tp_laboratorio_1
void listarSegunEstado(ArrayList* vuelos)
{
    int from=-1;
    int to=-1;
    ArrayList* aux;
    eVuelo* vuelo;
    char estado[20];
    int i,j;
    if(vuelos!= NULL)
    {
        al_sort(vuelos,comparaEstadoVuelos,0);
        strcpy(estado,validarEstado());
        for(i=0;i<vuelos->len(vuelos);i++)
         {
             vuelo=(eVuelo*)vuelos->get(vuelos,i);
             if(vuelo != NULL)
             {
                 if(strcmp(vuelo->estado,estado) == 0)
                 {
                    from=i;
                     break;
                 }
             }
         }
        if(from != -1)
        {
            to=from;
            for(j=from+1;j<vuelos->len(vuelos);j++)
            {
                vuelo=(eVuelo*)vuelos->get(vuelos,j);
                if(vuelo != NULL)
                {
                    if(strcmp(vuelo->estado,estado) == 0)
                    {
                            to=j;
                    }
                    else
                        break;
                }
            }
                aux=vuelos->subList(vuelos,from,to);
                if(aux != NULL)
                {
                    printArrayVuelos(aux,estado);
                    al_deleteArrayList(aux);
                }
        }
        else
            printf("No hay aviones para el estado elegido\n");
        }


    }
コード例 #4
0
ファイル: lib.c プロジェクト: GermanMoltoni/tp_laboratorio_1
int salir(ArrayList* vuelos,ArrayList* aviones)
{
    int retorno=-1;
    int i;
    if(vuelos != NULL && aviones != NULL)
        {
            if(!al_deleteArrayList(aviones))
            {
                for(i=0;i<aviones->len(aviones);i++)
                    free(*((aviones->pElements)+1));
                for(i=0;i<vuelos->len(vuelos);i++)
                    free(*((vuelos->pElements)+1));
                printf("Libero Memoria de Elementos utilizados\n");
                printf("Arraylist de aviones eliminado\n");
                if(!al_deleteArrayList(vuelos))
                {
                    printf("Arraylist de vuelos eliminado\n");
                    retorno=0;
                }
            }
        }
    return retorno;
}
コード例 #5
0
ファイル: thirdTest.c プロジェクト: Blacknux/ArrayList
void thirdTestCase02(void)
{

    int r;
    ArrayList* list;
    list = al_newArrayList();

    r = al_deleteArrayList(list);
    utest_assertEqualsIntMsg(r,0,"Error in return value <deleteArrayList> if array pointer is valid, the correct value to return is: (0)");

    if(r != 0)
        free(list);

}
コード例 #6
0
/** \brief Returns a new arrayList with a portion of pList between the specified
 *         fromIndex, inclusive, and toIndex, exclusive.
 * \param pList ArrayList* Pointer to arrayList
 * \param from int Initial index of the element (inclusive)
 * \param to int Final index of the element (exclusive)
 * \return int Return (NULL) if Error [pList is NULL pointer or invalid 'from' or invalid 'to']
 *                  - ( pointer to new array) if Ok
 */
ArrayList* al_subList(ArrayList* pList,int from,int to)
{
    void* datos;
    int i;
    ArrayList* list;
    list = al_newArrayList();

    if(pList != NULL && from >= 0 && to <= pList->size && to > from && to > 0 && from < pList->size)
    {
        for(i=from; i<=to; i++)
        {
            datos = pList->get(pList,i);
            pList->add(list,datos);
            // *((pList->pElements)+1+i) =  *((pList->pElements)+i);
        }
    } else {
            al_deleteArrayList(list);
            list=NULL;
            }
    return list;
}
コード例 #7
0
ファイル: funciones.c プロジェクト: JuanM96/tp_laboratorio_1
void listar(ArrayList* lista,ArrayList* listaDirec)
{
    int i,j;
    ArrayList* listaOrdenada;
    listaOrdenada=al_clone(lista);
    al_sort(listaOrdenada,compareFilms,0);
    ePelicula* pAuxP;
    eDirector* pAuxD;
    for(i=0; i<lista->size; i++)
    {
        pAuxP=al_get(listaOrdenada,i);
        for(j=0; j<listaDirec->size; j++)
        {
            pAuxD=al_get(listaDirec,j);
            if(pAuxP->director==pAuxD->codDirec)
            {
                break;
            }
        }
        printf("\nTitulo de la pelicula: %s\nDirector de la pelicula: %s\nNacionalidad de la pelicula: %s\nPuntaje: %d/100\n",pAuxP->titulo,pAuxD->nombre,pAuxP->nacionalidad,pAuxP->puntaje);
    }
    al_deleteArrayList(listaOrdenada);
}
コード例 #8
0
ファイル: funciones.c プロジェクト: JuanM96/tp_laboratorio_1
void informar(ArrayList* lista,ArrayList* listaDirec)
{
    int opcion;
    printf("1-Top 3 Mejores Peliculas\n");
    printf("2-Top 5 Peores Peliculas\n");
    scanf("%d",&opcion);
    switch(opcion)
    {
        case 1:
            if(lista->size>3)
            {
                int i,j;
                int largo;
                ArrayList* listaOrdenada;
                ArrayList* top3;
                listaOrdenada=al_clone(lista);
                al_sort(listaOrdenada,compareFilms,0);
                ePelicula* pAuxP;
                eDirector* pAuxD;
                top3=al_subList(listaOrdenada,0,2);
                largo=al_len(top3);
                for(i=0; i<largo; i++)
                {
                    pAuxP=al_get(top3,i);
                    for(j=0; j<listaDirec->size; j++)
                    {
                        pAuxD=al_get(listaDirec,j);
                        if(pAuxP->director==pAuxD->codDirec)
                        {
                            break;
                        }
                    }
                    printf("----------[%d]----------",(i+1));
                    printf("\nTitulo de la pelicula: %s\nDirector de la pelicula: %s\nNacionalidad de la pelicula: %s\nPuntaje: %d/100\n",pAuxP->titulo,pAuxD->nombre,pAuxP->nacionalidad,pAuxP->puntaje);
                }
                al_deleteArrayList(listaOrdenada);
                al_deleteArrayList(top3);
            }
            else
            {
                showMessage("IMPOSIBLE REALIZAR TOP SIN LA CANTIDAD CORRECTA DE PELICULAS");
            }
            break;
        case 2:
            if(lista->size>5)
            {
                int i,j;
                int largo;
                ArrayList* listaOrdenada;
                ArrayList* top5;
                listaOrdenada=al_clone(lista);
                al_sort(listaOrdenada,compareFilms,1);
                ePelicula* pAuxP;
                eDirector* pAuxD;
                top5=al_subList(listaOrdenada,0,4);
                largo=al_len(top5);
                for(i=0;i<largo;i++)
                {
                    pAuxP=al_get(top5,i);
                    for(j=0;j<listaDirec->size;j++)
                    {
                        pAuxD=al_get(listaDirec,j);
                        if(pAuxP->director==pAuxD->codDirec)
                        {
                            break;
                        }
                    }
                    printf("----------[%d]----------",(i+1));
                    printf("\nTitulo de la pelicula: %s\nDirector de la pelicula: %s\nNacionalidad de la pelicula: %s\nPuntaje: %d/100\n",pAuxP->titulo,pAuxD->nombre,pAuxP->nacionalidad,pAuxP->puntaje);
                }
                al_deleteArrayList(listaOrdenada);
                al_deleteArrayList(top5);
            }
            else
            {
                showMessage("IMPOSIBLE REALIZAR TOP SIN LA CANTIDAD CORRECTA DE PELICULAS");
            }
            break;
    }


}
コード例 #9
0
int main()
{
    system("color A");
    ArrayList* listaEmpleados=al_newArrayList();
    ArrayList* listaSectores=al_newArrayList();
    int cargar=load(listaEmpleados,listaSectores);
    if(cargar==0)
        printf("Exito al cargar los sectores\n");
    else if(cargar==1)
        printf("Exito al cargar sectores y empleados\n");
    char seguir='s';
    char guardar;
    system("pause");
    do
    {
        system("cls");
        int mainMenu=pedirNumero("1-ALTAS\n2-BAJAS\n3-MODIFICACIONES\n4-VER NOMINA\n5-GUARDAR\n6-SALIR\nIngrese una opcion:","Error al ingresar opcion\n");
        switch(mainMenu)
        {
        case 1: system("cls");
                altas(listaEmpleados,listaSectores);
                system("pause");
            break;

        case 2: system("cls");
                eliminar(listaEmpleados,listaSectores);
                system("pause");
            break;

        case 3: system("cls");
                modificar(listaEmpleados,listaSectores);
                system("pause");
            break;
        case 4: system("cls");
                mostrar(listaEmpleados,listaSectores);
                system("pause");
            break;
        case 5:
                    if(save(listaEmpleados,listaSectores)==0)
                        printf("\nDatos guardados correctamente");
                    else
                        printf("\nError al guardar!");

                    system("pause");
            break;
        case 6: system("cls");
                guardar=getChar("\nGuardar cambios?(s/n)");
                if(guardar=='s')
                {
                    if(save(listaEmpleados,listaSectores)==0)
                        printf("\nDatos guardados correctamente");
                    else
                        printf("\nError al guardar!");
                }
                al_deleteArrayList(listaEmpleados);
                al_deleteArrayList(listaSectores);
                seguir='n';
                system("pause");
            break;
        default:printf("Ingrese una opcion valida...\n");
        system("pause");
        }

    }while(seguir=='s');

    return 0;
}
コード例 #10
0
ファイル: main.c プロジェクト: JuanM96/tp_laboratorio_1
int main()
{
    char seguir='s';
    char save;
    int opcion;
    int flagPelicula=0;
    int flagDirector=0;
    int aux,aux2,aux3;
    int auxIsEmptyD,auxIsEmptyP;
    ArrayList* peliculas=al_newArrayList();
    ArrayList* directores=al_newArrayList();
    aux=cargarDesdeArchivoDirectores(directores);
    if(aux==0)
    {
        showMessage("LOS DIRECTORES SE CARGARON CON EXITO");
        system("pause");
        system("cls");
        auxIsEmptyD=al_isEmpty(directores);
        if(auxIsEmptyD==0)
        {
            flagDirector=1;
        }
    }
    aux2=cargarDesdeArchivoPeliculas(peliculas);
    if(aux2==0)
    {
        showMessage("LAS PELICULAS SE CARGARON CON EXITO");
        system("pause");
        system("cls");
        auxIsEmptyP=al_isEmpty(peliculas);
        if(auxIsEmptyP==0)
        {
            flagPelicula=1;
        }

    }
    printf("D=%d\nP=%d\n%d\n%d\n",flagDirector,flagPelicula,peliculas->size,directores->size);
    system("pause");
    system("cls");
    while(seguir=='s')
    {
        showMessage("1- ALTAS PELICULAS");
        showMessage("2- MODIFICAR DATOS DE UNA PELICULA");
        showMessage("3- BAJA DE PELICULA");
        showMessage("4- NUEVO DIRECTOR");
        showMessage("5- ELIMINAR DIRECTOR");
        showMessage("6- INFORMAR");
        showMessage("7- LISTAR");
        showMessage("8- BORRAR TODO");
        showMessage("9- SALIR");
        scanf("%d",&opcion);

        switch(opcion)
        {
            case 1:
                if(flagDirector==0)
                {
                    showMessage("PRIMERO INGRESE UN DIRECTOR");
                    system("pause");
                    system("cls");
                }
                else
                {
                    system("cls");
                    alta(peliculas,directores);
                    flagPelicula=1;
                }

                break;
            case 2:
                system("cls");
                if (flagPelicula==1)
                {
                    modificar(peliculas,directores);
                }
                else
                {
                    showMessage("ERROR, NO HAY PELICULAS REGISTRADAS");
                    system("pause");
                }
                break;
            case 3:
                system("cls");
                if (flagPelicula==1)
                {
                    baja(peliculas);
                }
                else
                {
                    showMessage("ERROR, NO HAY PELICULAS REGISTRADAS");
                    system("pause");
                    system("cls");
                }
                break;
            case 4:
                system("cls");
                nuevoDirector(directores);
                flagDirector=1;
                system("cls");
                break;
            case 5:
                system("cls");
                if (flagDirector==1)
                {
                    eliminarDirector(directores);
                }
                else
                {
                    showMessage("ERROR,NO HAY DIRECTORES REGISTRADOS");
                    system("pause");
                    system("cls");
                }
                break;
            case 6:
                system("cls");
                if (flagPelicula==1&&flagDirector==1)
                {
                    informar(peliculas,directores);
                    system("pause");
                    system("cls");
                }
                else
                {
                    showMessage("ERROR, NO HAY PELICULAS REGISTRADAS O NO HAY DIRECTORES REGISTRADOS");
                    system("pause");
                    system("cls");
                }
                break;
            case 7:
                system("cls");
                if (flagPelicula==1&&flagDirector==1)
                {
                    listar(peliculas,directores);
                    system("pause");
                    system("cls");
                }
                else
                {
                    showMessage("ERROR, NO HAY PELICULAS REGISTRADAS O NO HAY DIRECTORES REGISTRADOS");
                    system("pause");
                    system("cls");
                }
                break;
            case 8:
                system("cls");
                if (flagPelicula==1&&flagDirector==1)
                {
                    borrarTodo(peliculas,directores);
                }
                else
                {
                    showMessage("ERROR, NO HAY PELICULAS REGISTRADAS O NO HAY DIRECTORES REGISTRADOS");
                    system("pause");
                    system("cls");
                }
                break;
            case 9:
                showMessage("Guardar cambios S/N ?");
                fflush(stdin);
				scanf("%c",&save);
				save=tolower(save);
				if(save == 's')
				{
				    aux3=guardarEnArchivo(peliculas,directores);
					if(aux3==-1)
					{
						showMessage("No se pudo abrir el fichero");
						system("pause");
                        system("cls");
					}
					else
					{
						showMessage("Se guardo la informacion con exito");
						system("pause");
                        system("cls");
					}
				}
                al_deleteArrayList(peliculas);
                al_deleteArrayList(directores);
                seguir = 'n';
                break;
        }
    }

    return 0;
}