Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 83288af

Browse files
committed
Quase certo
1 parent d1c4bd4 commit 83288af

File tree

9 files changed

+70
-19
lines changed

9 files changed

+70
-19
lines changed

cpp/lista2jordana/Cliente.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#include "Cliente.hpp"
22

3-
Cliente::Cliente()
3+
Cliente::Cliente(string nome, string RG, string CPF, string end, string tel, string email)
44
{
55
this->pedidos = new vector<Pedido *>;
6+
7+
this->setNome(nome);
8+
// this->setDataNascimento(dataNasc);
9+
this->setRG(RG);
10+
this->setCPF(CPF);
11+
this->setEndereco(end);
12+
this->setTelefone(tel);
13+
this->setEmail(email);
14+
615
cout << "Cliente criado." << endl;
716
}
817

cpp/lista2jordana/Cliente.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Cliente
2121
vector<Pedido *> *pedidos;
2222

2323
public:
24-
Cliente();
24+
Cliente(string nome, string RG, string CPF, string end, string tel, string email);
2525
~Cliente();
2626

2727
string getNome();

cpp/lista2jordana/Funcionario.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
#include "Funcionario.hpp"
22

3-
Funcionario::Funcionario()
4-
{
3+
Funcionario::Funcionario(string nome, string matricula, string RG, string CPF, string end, string tel, string email)
4+
{
5+
this->setNome(nome);
6+
// this->setDataNascimento(dataNasc);
7+
this->setRG(RG);
8+
this->setCPF(CPF);
9+
this->setEndereco(end);
10+
this->setTelefone(tel);
11+
this->setEmail(email);
12+
513
cout << "Funcionario criado." << endl;
614
}
715

cpp/lista2jordana/Funcionario.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Funcionario
2020
string matricula;
2121

2222
public:
23-
Funcionario();
23+
Funcionario(string nome, string matricula, string RG, string CPF, string end, string tel, string email);
2424
~Funcionario();
2525

2626
string getMatricula();

cpp/lista2jordana/Pedido.cpp

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1+
#include <string.h>
12
#include "Pedido.hpp"
23

3-
Pedido::Pedido(Funcionario *fun, ItemDePedido *ped)
4+
Pedido::Pedido(Funcionario *fun, vector<ItemDePedido *> ped, string formaPgto)
45
{
5-
this->funcionario = fun;
6+
this->setFuncionario(fun);
7+
this->setFormaPgto(formaPgto);
8+
69
this->itens = new vector<ItemDePedido *>;
7-
this->itens->push_back(ped);
10+
int qtdItens = ped.size();
11+
for (int i = 0; i < qtdItens; i++)
12+
{
13+
this->itens->push_back(ped[i]);
14+
15+
if (ped[i]->getProduto()->getQtdEstoque() > 0)
16+
{
17+
if (formaPgto.compare("Aguardando") == 0)
18+
{
19+
this->setStatus("Pedido aguardando pagamento");
20+
}
21+
else
22+
{
23+
this->setStatus("Pedido registrado");
24+
}
25+
}
26+
else
27+
{
28+
this->setStatus("Pedido aguardando estoque");
29+
}
30+
}
831

932
Pedido::qtdPedidos++;
10-
cout << "Novo pedido." << endl;
33+
cout << "Novo pedido criado." << endl;
1134
}
1235

1336
Pedido::~Pedido()
1437
{
15-
// delete this->funcionario;
1638
int tamItens = this->itens->size();
1739
for (int i = 0; i < tamItens; i++)
1840
{
@@ -84,6 +106,11 @@ vector<ItemDePedido *> *Pedido::getItensDePedido()
84106
return this->itens;
85107
}
86108

109+
void Pedido::setFuncionario(Funcionario *fun)
110+
{
111+
this->funcionario = fun;
112+
}
113+
87114
Funcionario *Pedido::getFuncionario()
88115
{
89116
return this->funcionario;

cpp/lista2jordana/Pedido.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class Pedido
2222

2323
public:
2424
static int qtdPedidos;
25-
Pedido(Funcionario *fun, ItemDePedido *ped);
25+
// Pedido(Funcionario *fun, ItemDePedido *ped);
26+
Pedido(Funcionario *fun, vector<ItemDePedido *> ped, string formaPgto);
2627
~Pedido();
2728

2829
float getValorTotal();
@@ -37,6 +38,7 @@ class Pedido
3738
void setQtdPedidos(int qtdPedidos);
3839
void adicionarItens(ItemDePedido *ped);
3940
vector<ItemDePedido *> *getItensDePedido();
41+
void setFuncionario(Funcionario *fun);
4042
Funcionario *getFuncionario();
4143
};
4244

cpp/lista2jordana/Produto.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#include "Produto.hpp"
22

3-
Produto::Produto()
3+
Produto::Produto(int codigo, string nome, string descricao, int qtd)
44
{
5+
this->setCodigo(codigo);
6+
this->setNome(nome);
7+
this->setDescricao(descricao);
8+
this->setQtdEstoque(qtd);
9+
510
this->qtdProdutos++;
611
cout << "Produto criado." << endl;
712
}

cpp/lista2jordana/Produto.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class Produto
1818

1919
public:
2020
static int qtdProdutos;
21+
Produto(int codigo, string nome, string descricao, int qtd);
2122
~Produto();
22-
Produto();
2323

2424
int getCodigo();
2525
void setCodigo(int codigo);

cpp/lista2jordana/lista2.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ int main()
1616
Funcionario *fun;
1717
Pedido *ped;
1818
Produto *prod;
19-
ItemDePedido *itemPed;
19+
vector<ItemDePedido *> itemPed;
2020

2121
cout << "Testando inicializacao de objetos.\n" << endl;
2222

23-
cli = new Cliente();
23+
cli = new Cliente("Tiaguin", "168", "59", "rua", "777", "_battlenet");
2424
cli->setNome("Renan");
25-
prod = new Produto();
25+
prod = new Produto(2832, "V5", "gel", 10);
2626
prod->setNome("docin");
2727
prod->setCodigo(2832);
28-
fun = new Funcionario();
28+
fun = new Funcionario("Tiaguin", "2832", "168", "59", "rua", "777", "_battlenet");
2929
fun->setNome("Tiaguin");
3030

31-
itemPed = new ItemDePedido(prod);
32-
ped = new Pedido(fun, itemPed);
31+
// itemPed = new vector<ItemDePedido *>;
32+
ped = new Pedido(fun, itemPed, "Aguardando");
3333
cli->adicionarPedido(ped);
3434

3535
cout << "Funcionario encarregado pelo primeiro pedido do cliente " << cli->getNome() << ": " << cli->getPedidos()->at(0)->getFuncionario()->getNome() << endl;

0 commit comments

Comments
 (0)