Skip to content

Commit

Permalink
criando a funcao de quit // comencando a deixar bonito
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaian-k committed Jul 3, 2022
1 parent 93b74b9 commit 3bad49f
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 35 deletions.
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"stdio.h": "c",
"stdlib.h": "c",
"fila_prioridade.h": "c",
"abb.h": "c"
"abb.h": "c",
"ncurses.h": "c"
}
}
10 changes: 5 additions & 5 deletions abb.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void add_abb(Abb_node *new, Abb_node *aux, int id){
else {aux->right = new;}}}


Abb_node *remover_abb(Abb_node *root, int id){
Abb_node *remover_abb(Abb_node *root, int id, Abb_node *backup){
if (root == NULL){
printf("Valor nao encontrado!\n"); return NULL;}

Expand All @@ -50,7 +50,7 @@ Abb_node *remover_abb(Abb_node *root, int id){
root->id = aux->id;
aux->id = id;

root->left = remover_abb(root->left, id);
root->left = remover_abb(root->left, id, backup);
return root;}

else { //com 1 filho
Expand All @@ -61,8 +61,8 @@ Abb_node *remover_abb(Abb_node *root, int id){
free(root); return aux;}}}

else {
if (id < root->id){root->left = remover_abb(root->left, id);}
else {root->right = remover_abb(root->right, id);} return root;}}}
if (id < root->id){root->left = remover_abb(root->left, id, backup);}
else {root->right = remover_abb(root->right, id, backup);} return root;}}}


void in_ordem(Abb_node *aux){
Expand All @@ -78,7 +78,7 @@ void in_ordem(Abb_node *aux){

if (aux->right != NULL){in_ordem(aux->right);}}

else {printf("Não foi encontrada nenhuma encomenda pendente.\n\n");}}
else {printf("\nNão foi encontrada nenhuma encomenda pendente.\n\n");}}


void node_imprimir(int id, int espaco) { //funcao aux da: abb_exibir_estrutura
Expand Down
10 changes: 5 additions & 5 deletions fila_pre_cadastrados.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ void fifopre_add(char *nome, char *senha, int cpf, char cargo){
fifopre_last = novo; fifopre_tam++;}}


void fifopre_imprimir(){
Fifopre_node *aux = fifopre_start;
for (int i=0; i<fifopre_tam; i++){
printf("Nome dos cadastrados: %s - Cargo: %c\n", aux->admin.nome, aux->admin.cargo);
aux = aux->next;}}
void fifopre_imprimir(Fifopre_node *aux){
if (aux != NULL){
printf("%s - Cargo: %c\n", aux->admin.nome, aux->admin.cargo);
printf("--------------------------------------------\n");
fifopre_imprimir(aux->next);}}


void add_pre_cadastrados(){
Expand Down
7 changes: 3 additions & 4 deletions fila_prioridade.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ void add_fila(int id, int prioridade, char *nome_aluno, int matricula, char *des
fifop_tam++;}}


void imprimir(){
Fifop_node *aux = fifop_start;
for (int i=0; i<fifop_tam; i++){
void imprimir(Fifop_node *aux){
if (aux != NULL){
printf("Identificador: %d\n", aux->pedido->id);
aux = aux->next;}}
imprimir(aux->next);}}


Pedido remover_fila(){
Expand Down
13 changes: 8 additions & 5 deletions fuctions_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ int add_esq_ou_dir = 0;

//fuctions

void quit(){
while (getchar() != 'q'){printf("\n\nPressione: q, para sair: ");};}


Fifopre_node *verificar_senha(Fifopre_node *aux, char cargo){
int cpf; char senha[100];

Expand Down Expand Up @@ -93,13 +97,12 @@ void remover_encomenda(){

if (admin != NULL){
//create variables
int selecionar_id; Abb_node *lixo = buscar(selecionar_id, root);
int selecionar_id; Abb_node *backup = malloc(sizeof(Abb_node));

printf(" Digite o id da encomenda que deseja remover:\n"); scanf("%d", &selecionar_id);

if (lixo != NULL){
root = remover_abb(root, selecionar_id);

root = remover_abb(root, selecionar_id, backup);
if (backup != NULL){
//setar novos dados (faltando)
printf("Digite o nome do campus do aluno:\n");
char *nome_campus_aluno = malloc(sizeof(char)); scanf(" %[^\n]s", nome_campus_aluno);
Expand All @@ -110,7 +113,7 @@ void remover_encomenda(){
printf("Informe a prioridade do pedido (0 à 100):\n");
int prioriadade; scanf("%d", &prioriadade);

add_fila(lixo->id, prioriadade, lixo->nome_aluno, lixo->matricula, lixo->descricao, admin->admin.nome, nome_campus_aluno, nome_campus_livro);}}
add_fila(backup->id, prioriadade, backup->nome_aluno, backup->matricula, backup->descricao, admin->admin.nome, nome_campus_aluno, nome_campus_livro);}}

else {
printf("\nSenha incorreta!\n\n");}}
Expand Down
Binary file modified principal
Binary file not shown.
66 changes: 51 additions & 15 deletions principal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,75 @@
//file
#include "fuctions_system.h"

//detectando o sistema operacional
#ifdef __unix__
char clear[] = "clear";

#elif defined(_WIN32) || defined(WIN32)
char clear[] = "cls";

#endif

//definindo cores (ANSI)
#define RESET "\033[0;0m"
//fonts
#define FONT_GRAY "\033[1;37m"
#define FONT_BLACK "\033[1;30m"
#define FONT_RED "\033[1;31m"
#define FONT_BLUE "\033[1;94m"
//backgrounds
#define BACKGROUND_BLACK "\033[1;40m"
#define BACKGROUND_GRAY "\033[1;47m"

int main(){
//cadastrando secretarios e transportadores
add_pre_cadastrados(); fifopre_imprimir();

int main(){
//create variables
int resp;

while (resp != 0){
printf("\n<<<SISTEMA DE ENCOMENDA DE LIVRO>>>\n\n");
printf(" 1 - Encomendar um livro.\n" //sem pedir senha
system(clear);
printf(BACKGROUND_BLACK "\n<<< SISTEMA DE ENCOMENDA DE LIVRO >>>\n-------------------------------------\n");
printf(BACKGROUND_GRAY FONT_BLUE " 1 - Encomendar um livro.\n" //sem pedir senha
" 2 - Remover uma encomenda de livro.\n" //secretario - pedir senha
" 3 - Remover um pedido de livro.\n" //transportadores - pedir senha
" 0 - Sair do sistema!\n"
"\nDigite a funcionalidade desejada: "); scanf("%d", &resp);
" 3 - Remover um pedido de livro. \n" //transportadores - pedir senha
" 4 - Exibir encomendas. \n"
" 5 - Exibir pedidos. \n"
" 6 - Exibir usuarios cadastrados. \n"
" 0 - Sair do sistema! \n"
RESET FONT_BLUE "\nDigite a funcionalidade desejada: "); scanf("%d", &resp);

switch (resp){
case 1: //encomendar um livro
encomendar(); break;
system(clear); encomendar(); quit(); break;

case 2:
//validacao: cpf e senha
remover_encomenda(); break;
system(clear); remover_encomenda(); quit(); break;

case 3:
remover_pedido(); break;
system(clear); remover_pedido(); quit(); break;

case 4:
system(clear); in_ordem(root); quit(); break;

case 5:
system(clear);
if (fifop_start != NULL){imprimir(fifop_start);}
else {printf("\nNão existe nenhum pedido cadastrado no momento.\n\n");}

quit(); break;

case 6:
system(clear); printf("\n<<< Usuarios cadastrados >>>\n\n");
fifopre_imprimir(fifopre_start);
quit(); break;

case 1815: //OPCAO ESPECIAL (Ada Lovelace - reference)
printf("\n\n===Exibir estrutura da ABB (Graficamente)===\n\n");
system(clear); printf("\n\n<<< Exibir estrutura da ABB (Graficamente) >>>\n-----------------------------------\n\n");
abb_exibir_estrutura(root, 1);
printf("\n============================================\n\n\n"); break;
printf("\n============================================\n\n\n");
quit(); break;

default:
printf("\n\nSelecione uma opção valida!\n\n"); break;}}

return 0;}
system(clear); printf("Programa finalizado!\n\n"); return 0;}

0 comments on commit 3bad49f

Please sign in to comment.