#include "lista_string.h"

/*
* =================================================
*    Filename:  .c
* Description:
*     Created:  dd/mm/18 hh:mm
* =================================================
*/

int imprime_op();

int main(int argc, char **argv)
{
	int op = -1;
	char v[MAX];

	Lista *L1;
	L1 = cria_lista();

	system("clear");
	while(op != 4)
	{
		op = imprime_op();
		switch(op)
		{
			case 1:
				printf("String a ser inserido: ");
				setbuf(stdin,NULL);
				scanf("%[^\n]s", v);
				if(insere_elem(L1,v))
					printf("Elemento inserido!\n");
				else
					printf("Elemento nao inserido!\n");
				setbuf(stdin,NULL);
				getchar();
				break;
			case 2:
				printf("Qual string sera removido? ");
				setbuf(stdin,NULL);
				scanf("%[^\n]s", v);
				if(remove_elem(L1, v))
					printf("Elemento removido\n");
				else
					printf("Elemento nao removido\n");
				getchar();
				break;
			case 3:
				system("clear");
				print_lista(L1);
				getchar();
				system("clear");
				break;
		}

		return 0;
	}
}

int imprime_op()
{
	int op;

	do
	{
		printf("---------------- Qual a operacao? -----------------\n");
		printf("[1] - Inserir uma string à lista\n");
		printf("[2] - Remover uma string da lista\n");
		printf("[3] - Imprimir a lista\n");
		printf("[4] - Sair do programa\n");
		printf("Operacao: "); setbuf(stdin,NULL);
		scanf("%d", &op);
	} while(op < 0 || op > 4);

	return op;
}

