int main() {
Queue fast,normal;
Element element;
char comando;
int cantidad;
char nombre[MAX_NAME_LENGTH];
char basura;
fast = QUEUE_create();
normal = QUEUE_create();
/*
F -> Fast
N -> Normal
A -> Enter attraction
Q -> Quit
*/
do {
scanf("%c",&comando); //Solo roba hasta el ' ' o el '\n'
scanf("%c",&basura); //Roba el espacio o el salto de linea
switch(comando) {
case 'F':
scanf("%d",&element.size);
scanf("%c",&basura);
scanf("%s",element.name);
scanf("%c",&basura);
QUEUE_add(&fast,element);
if(QUEUE_NO_ERROR == QUEUE_getErrorCode(fast)) {
printf("%s (%d) has been added to the Fast queue.\n",element.name,element.size);
} else {
if(QUEUE_ERROR_FULL == QUEUE_getErrorCode(fast)) {
printf("The Fast queue is full.\n");
}
}
break;
case 'N':
scanf("%d",&element.size);
scanf("%c",&basura);
scanf("%s",element.name);
scanf("%c",&basura);
QUEUE_add(&fast,element);
if(QUEUE_NO_ERROR == QUEUE_getErrorCode(normal)) {
printf("%s (%d) has been added to the Normal queue.\n",element.name,element.size);
} else {
if(QUEUE_ERROR_FULL == QUEUE_getErrorCode(normal)) {
printf("The Normal queue is full.\n");
}
}
break;
case 'A':
if(QUEUE_getErrorCode(fast) != QUEUE_ERROR_EMPTY) {
//No esta vacia! vamos a fast
element = QUEUE_getFirst(&fast);
printf("%s (%d) has entered the attraction.\n",element.name,element.size);
QUEUE_remove(&fast);
} else {
if(QUEUE_getErrorCode(normal) != QUEUE_ERROR_EMPTY) {
//No esta vacia!
element = QUEUE_getFirst(&normal);
printf("%s (%d) has entered the attraction.\n",element.name,element.size);
QUEUE_remove(&normal);
} else {
//Las dos estan vacias!
printf("No group is available yet.\n");
}
}
break;
case 'Q':
QUEUE_destroy(&fast);
QUEUE_destroy(&normal);
printf("See you soon!\n");
break;
}
}while(comando != 'Q');
return 0;
}