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

6d42a9d0df1a8f28ec9f47b45ed8f283 #32

Open
wants to merge 4 commits into
base: main
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/*.o
/vpl_exec
26 changes: 0 additions & 26 deletions Banco.hpp

This file was deleted.

33 changes: 0 additions & 33 deletions ContaBancaria.hpp

This file was deleted.

23 changes: 0 additions & 23 deletions ContaCorrente.hpp

This file was deleted.

18 changes: 0 additions & 18 deletions ContaPoupanca.hpp

This file was deleted.

35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
CC=g++
CFLAGS=-std=c++11 -Wall
TARGET=vpl_exec

TARGET_DIR = .
BUILD_DIR = ./build
SRC_DIR = ./src
INCLUDE_DIR = ./include

all: ${TARGET_DIR}/${TARGET}

run: all
./${TARGET_DIR}/${TARGET}

clean:
rm -f ${BUILD_DIR}/*
rm -f ${TARGET_DIR}/${TARGET}

${TARGET_DIR}/${TARGET}: ${BUILD_DIR}/Banco.o ${BUILD_DIR}/ContaBancaria.o ${BUILD_DIR}/ContaCorrente.o ${BUILD_DIR}/ContaPoupanca.o ${BUILD_DIR}/main.o
${CC} ${CFLAGS} ${BUILD_DIR}/*.o -o ${TARGET_DIR}/${TARGET}

${BUILD_DIR}/Banco.o: ${INCLUDE_DIR}/ContaBancaria.hpp ${INCLUDE_DIR}/ContaCorrente.hpp ${INCLUDE_DIR}/ContaPoupanca.hpp ${INCLUDE_DIR}/Banco.hpp ${SRC_DIR}/Banco.cpp
${CC} ${CFLAGS} -I ${INCLUDE_DIR}/ -c ${SRC_DIR}/Banco.cpp -o ${BUILD_DIR}/Banco.o

${BUILD_DIR}/ContaBancaria.o: ${INCLUDE_DIR}/ContaBancaria.hpp ${SRC_DIR}/ContaBancaria.cpp
${CC} ${CFLAGS} -I ${INCLUDE_DIR}/ -c ${SRC_DIR}/ContaBancaria.cpp -o ${BUILD_DIR}/ContaBancaria.o

${BUILD_DIR}/ContaCorrente.o: ${INCLUDE_DIR}/ContaBancaria.hpp ${INCLUDE_DIR}/ContaCorrente.hpp ${SRC_DIR}/ContaCorrente.cpp
${CC} ${CFLAGS} -I ${INCLUDE_DIR}/ -c ${SRC_DIR}/ContaCorrente.cpp -o ${BUILD_DIR}/ContaCorrente.o

${BUILD_DIR}/ContaPoupanca.o: ${INCLUDE_DIR}/ContaBancaria.hpp ${INCLUDE_DIR}/ContaPoupanca.hpp ${SRC_DIR}/ContaPoupanca.cpp
${CC} ${CFLAGS} -I ${INCLUDE_DIR}/ -c ${SRC_DIR}/ContaPoupanca.cpp -o ${BUILD_DIR}/ContaPoupanca.o

${BUILD_DIR}/main.o: ${INCLUDE_DIR}/ContaCorrente.hpp ${INCLUDE_DIR}/ContaPoupanca.hpp ${INCLUDE_DIR}/Banco.hpp ${SRC_DIR}/main.cpp
${CC} ${CFLAGS} -I ${INCLUDE_DIR}/ -c ${SRC_DIR}/main.cpp -o ${BUILD_DIR}/main.o
25 changes: 25 additions & 0 deletions include/Banco.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef BANCO_H
#define BANCO_H

#include <iostream>
#include <vector>
#include "ContaBancaria.hpp"
#include "ContaCorrente.hpp"
#include "ContaPoupanca.hpp"

class Banco {
private:
std::vector<ContaBancaria*> _contas;
void adicionarConta(ContaBancaria* conta);


public:
~Banco();

ContaCorrente* criarContaCorrente(std::string titular, double saldo, double limite_cheque_especial);
ContaPoupanca* criarContaPoupanca(std::string titular, double saldo, double taxa_juros);

void exibirTodasContas();
};

#endif
28 changes: 28 additions & 0 deletions include/ContaBancaria.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef CONTA_BANCARIA_H
#define CONTA_BANCARIA_H

#include <iostream>
#include <string>

class ContaBancaria {
private:
std::string _titular;


protected:
double _saldo;
bool checarValorValido(double valor);
bool checarSaldoSuficiente(double valor);


public:
ContaBancaria(std::string titular, double saldo);
virtual ~ContaBancaria() = 0;

void depositar(double valor);
void sacar(double valor);

void exibirInfo();
};

#endif
19 changes: 19 additions & 0 deletions include/ContaCorrente.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef CONTA_CORRENTE_H
#define CONTA_CORRENTE_H

#include "ContaBancaria.hpp"

class ContaCorrente : public ContaBancaria {
private:
double _limite_cheque_especial;
bool checarLimiteSuficiente(double valor);


public:
ContaCorrente(std::string titular, double saldo, double limite_cheque_especial);
void usarChequeEspecial(double valor);

};


#endif
20 changes: 20 additions & 0 deletions include/ContaPoupanca.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef CONTA_POUPANCA_H
#define CONTA_POUPANCA_H

#include "ContaBancaria.hpp"

class ContaPoupanca : public ContaBancaria {
private:
static double constexpr _PROPORCAO_PERCENTUAL_DECIMAL = 100;
double _taxa_juros;
double calcularValorJuros();


public:
ContaPoupanca(std::string titular, double saldo, double taxa_juros);
void calcularJuros();

};


#endif
71 changes: 0 additions & 71 deletions main.cpp

This file was deleted.

33 changes: 33 additions & 0 deletions src/Banco.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "Banco.hpp"

void Banco::adicionarConta(ContaBancaria* conta) {
this->_contas.push_back(conta);
}


Banco::~Banco(){
for (ContaBancaria* conta : this->_contas) {
delete conta;
}
}


ContaCorrente* Banco::criarContaCorrente(std::string titular, double saldo, double limite_cheque_especial){
ContaCorrente* nova_conta = new ContaCorrente(titular, saldo, limite_cheque_especial);
this->adicionarConta(nova_conta);
return nova_conta;
}


ContaPoupanca* Banco::criarContaPoupanca(std::string titular, double saldo, double taxa_juros){
ContaPoupanca* nova_conta = new ContaPoupanca(titular, saldo, taxa_juros);
this->adicionarConta(nova_conta);
return nova_conta;
}


void Banco::exibirTodasContas() {
for (ContaBancaria* conta : this->_contas) {
conta->exibirInfo();
}
}
Loading