forked from Felipe-Visgou/gitproj2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBAR.c
158 lines (126 loc) · 3.52 KB
/
BAR.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/***************************************************************************
* $MCI Módulo de implementação: BAR Peças Capturadas
*
* Arquivo gerado: BAR.c
* Letras identificadoras: BAR
*
* Nome da base de software: Arcabouço para a automação de testes de programas redigidos em C
*
* Projeto: INF 1301 / 1628 Automatização dos testes de módulos C
* Gestor: LES/DI/PUC-Rio
* Autores: fvc
tbm
db
*
* $HA Histórico de evolução:
* Versão Autor Data Observações
1.0 fvc 18/10 Começo do Desenvolvimento
*
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include "LISTA.h"
#include "PECA.h"
#define BAR_OWN
#include "BAR.h"
#undef BAR_OWN
/***********************************************************************
*
* $TC Tipo de dados: BAR Descritor da BAR
*
*
***********************************************************************/
typedef struct BAR_tagCapturadas {
LIS_tppLista ListaCapturadas;
/* Lista de Peças Capturadas*/
char cor;
/* A cor das peças do BAR */
int tamanho ;
/* Número de elementos no BAR*/
} BAR_tpCapturadas ;
/***** Código das funções exportadas pelo módulo *****/
/***************************************************************************
*
* Função: TAB &Criar BAR
* ****/
BAR_tpCondRet BAR_CriarBAR(BAR_tppCapturadas *pBAR, char cor, void ( * ExcluirValor ) ( void * pDado ) )
{
*pBAR = (BAR_tppCapturadas)malloc(sizeof(BAR_tpCapturadas));
if(*pBAR == NULL)
return BAR_CondRetFaltouMemoria;
(*pBAR)->ListaCapturadas = LIS_CriarLista(ExcluirValor);
(*pBAR)->cor = cor;
(*pBAR)->tamanho = 0;
return BAR_CondRetOK;
}
/***************************************************************************
*
* Função: TAB &Adicionar Peça
* ****/
BAR_tpCondRet BAR_AdicionarPeca(BAR_tppCapturadas pBAR)
{
char cor = pBAR->cor;
tppPeca newPeca;
if(Pec_CriarPeca(&newPeca, cor) != Pec_CondRetOK)
{
printf("Erro ao criar peca (BAR) \n");
return BAR_CondRetErro;
}
if(LIS_InserirElementoApos(pBAR->ListaCapturadas, newPeca) != LIS_CondRetOK)
{
printf("Erro ao inserir peça na lista (BAR) \n");
return BAR_CondRetErro;
}
pBAR->tamanho++;
return BAR_CondRetOK;
}
/***************************************************************************
*
* Função: TAB &RemoverPeça
* ****/
BAR_tpCondRet BAR_RemoverPeca(BAR_tppCapturadas pBAR)
{
if(LIS_ExcluirElemento(pBAR->ListaCapturadas) != LIS_CondRetOK)
{
printf("Erro ao excluir peca da lsita (BAR) \n");
return BAR_CondRetErro;
}
pBAR->tamanho--;
return BAR_CondRetOK;
}
/***************************************************************************
*
* Função: TAB &Obter Tamanho BAR
* ****/
BAR_tpCondRet BAR_ObterTamanhoBar(BAR_tppCapturadas pBAR, int *tam)
{
if(tam == NULL)
return BAR_CondRetErro;
*tam = pBAR->tamanho;
if(*tam == 0)
return BAR_CondRetVazia;
return BAR_CondRetOK;
}
/***************************************************************************
*
* Função: TAB &Obter cor BAR
* ****/
BAR_tpCondRet BAR_ObterCorBar(BAR_tppCapturadas pBAR, char *cor)
{
if(cor == NULL)
return BAR_CondRetErro;
*cor = pBAR->cor;
return BAR_CondRetOK;
}
/*BAR_tpCondRet BAR_ObterListaBAR(BAR_tppCapturadas pBar, LIS_tppLista *pLista)
{
*pLista = pBar->ListaCapturadas;
if(pLista == NULL || *pLista == NULL)
{
printf("Ponterio para bar eh nulo (BAR) \n");
return BAR_CondRetErro;
}
return BAR_CondRetOK;
}*/
/******** Fim do Módulo de Implementação: BAR Lista de Peças Capturadas *************/