Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aluno #154 #154

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions Cliente.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
#include <string>
#include "Cliente.hpp"

void Cliente::print(){
Cliente::Cliente(string nome, Endereco *endereco) {
this->nome = nome;
this->endereco = endereco;
}

Cliente::~Cliente() {
//delete this->endereco;
}

std::cout << " Nome: " << NOME << endl
<< " Endereço: " << endereco << endl
<< " Cidade: " << CIDADE << endl
<< " Estado: " << ESTADO << endl
<< " CEP: " << cep << endl;
void Cliente::print(){
std::cout << " Nome: " << nome << endl
<< " Endereço: " << endereco->getLogradouro() << endl
<< " Cidade: " << endereco->getCidade() << endl
<< " Estado: " << endereco->getEstado() << endl
<< " CEP: " << endereco->getCep() << endl;

}
}
18 changes: 10 additions & 8 deletions Cliente.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
#define CLIENTE_H

#include <string>
#include "Endereco.hpp"

using namespace std;

class Cliente{
class Cliente {

private:
string nome;
Endereco *endereco;

public:
Cliente(string nome, Endereco *endereco);

string NOME;
string endereco;
string CIDADE;
string ESTADO;
string cep;
~Cliente();

void print(); // imprime na tela os dados de um cliente cadastrado

void print();
};

#endif
23 changes: 23 additions & 0 deletions Encomenda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <string>

#include "Encomenda.hpp"

Encomenda::Encomenda(double peso, double custoPorkg, Cliente *remetente, Cliente *destinatario) {
this->peso = peso;
this->custoPorkg = custoPorkg;
this->remetente = remetente;
this->destinatario = destinatario;
}

double Encomenda::getCustoTotal() {
return this->custoTotal;
}

void Encomenda::print() {
std::cout << "[Remetente]" << endl;
this->remetente->print();
std::cout << "[Destinatário]" << endl;
this->destinatario->print();
this -> _print();
}
29 changes: 16 additions & 13 deletions Encomenda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@
#define Encomenda_H

#include "Cliente.hpp"

using namespace std;

class Encomenda{
class Encomenda {

protected:

double peso = 0.0;
double custoPorkg = 0.0;
double custoTotal = 0.0;
Cliente *remetente;
Cliente *destinatario;

virtual void _print() {}
virtual void _calculaCustoTotal() {}

public:

double PESO = 0.0;
double CUSTOkg = 0.0;
double T = 0.0;
Cliente remetente;
Cliente dest;

void print(){
Encomenda(double peso, double custoPorkg, Cliente *remetente, Cliente *destinatario);

std::cout << "[Remetente]" << endl;
remetente.print();
std::cout << "[Destinatário]" << endl;
dest.print();
}
double getCustoTotal();

void print();
};

#endif
31 changes: 16 additions & 15 deletions EncomendaNormal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@

#include "Encomenda.hpp"
#include "Cliente.hpp"
using namespace std;

class EncomendaNormal: public Encomenda{
using namespace std;

public:

double calcula(){
class EncomendaNormal: public Encomenda {

double x = PESO * CUSTOkg;
private:

return x;
}
void _print() override {
std::cout << "[Encomenda Normal]" << endl;
std::cout << " Peso: " << peso << endl
<< " Custo por kg: " << custoPorkg << endl
<< " Custo total: " << custoTotal << endl;
}

void print(){
void _calculaCustoTotal() override {
custoTotal = peso * custoPorkg;
}

Encomenda::print();
std::cout << "[Encomenda Normal]" << endl;
std::cout << " Peso: " << PESO << endl
<< " Custo por kg: " << CUSTOkg << endl
<< " Custo total: " << T << endl;
public:

}
EncomendaNormal(double peso, double custoPorkg, Cliente *remetente, Cliente *destinatario) : Encomenda(peso, custoPorkg, remetente, destinatario) {
_calculaCustoTotal();
}

};

Expand Down
34 changes: 19 additions & 15 deletions EncomendaRelampago.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@

#include "Encomenda.hpp"
#include "Cliente.hpp"
using namespace std;

class EncomendaRelampago: public Encomenda{
#define TAXA_ADICIONAL 0.25

public:
using namespace std;

class EncomendaRelampago: public Encomenda {

double calcula(){
private:

double x = PESO * CUSTOkg;
x += x * 0.25;

return x;
void _print() override {
std::cout << "[Encomenda Relâmpago]" << endl;
std::cout << " Peso: " << peso << endl
<< " Custo por kg: " << custoPorkg << endl
<< " Taxa adicional: " << TAXA_ADICIONAL << endl
<< " Custo total: " << custoTotal << endl;
}

void print(){
void _calculaCustoTotal() override {
double valor = peso * custoPorkg;
valor += valor * TAXA_ADICIONAL;
custoTotal = valor;
}

Encomenda::print();
std::cout << "[Encomenda Relâmpago]" << endl;
std::cout << " Peso: " << PESO << endl
<< " Custo por kg: " << CUSTOkg << endl
<< " Taxa adicional: " << 0.25 << endl
<< " Custo total: " << T << endl;
public:

EncomendaRelampago(double peso, double custoPorkg, Cliente *remetente, Cliente *destinatario) : Encomenda(peso, custoPorkg, remetente, destinatario) {
_calculaCustoTotal();
}

};
Expand Down
25 changes: 25 additions & 0 deletions Endereco.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <string>
#include "Endereco.hpp"

Endereco::Endereco(string logradouro, string cidade, string estado, string cep) {
this->logradouro = logradouro;
this->cidade = cidade;
this->estado = estado;
this->cep = cep;
}

string Endereco::getLogradouro() {
return this->logradouro;
}

string Endereco::getCidade() {
return this->cidade;
}

string Endereco::getEstado() {
return this->estado;
}

string Endereco::getCep() {
return this->cep;
}
24 changes: 24 additions & 0 deletions Endereco.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef ENDERECO_H
#define ENDERECO_H

#include <string>
using namespace std;

class Endereco {

private:
string logradouro;
string cidade;
string estado;
string cep;

public:
Endereco(string logradouro, string cidade, string estado, string cep);

string getLogradouro();
string getCidade();
string getEstado();
string getCep();
};

#endif
Loading