diff --git a/main.cpp b/main.cpp index 7d830a6e39c81d2d607fec198189036284e1fa39..155221ddba6a91d159ba45f47fe9e34c8188dee9 100644 --- a/main.cpp +++ b/main.cpp @@ -38,13 +38,16 @@ int main(){ Biblioteca bib; // Cria Usuarios - ControladorUsuarios contUsuarios = bib.getContUsuarios(); - cout << "> Criando Usuarios" << endl; + ControladorUsuarios contUsuarios = bib.getContUsuarios(); contUsuarios.adicionarUsuario("Muriki", "12345", "Casa", "9999", "murikigy@gmail.com"); contUsuarios.adicionarUsuario("Nico", "54321", "Apartamento", "8888", "nico@gmail.com"); contUsuarios.adicionarUsuario("Marcus", "12345", "Casa", "9988", "marcus@gmail.com"); + // Cria Obras + cout << ""; + + // Interation Loop int option = START; while (option != FINISH) { diff --git a/sources/ControladorUsuarios.cpp b/sources/ControladorUsuarios.cpp index e13249350e1668e9dfa6dc078463b2cfddda357c..15b2220f938ac5654f95e8882c52f9e9b1031f82 100644 --- a/sources/ControladorUsuarios.cpp +++ b/sources/ControladorUsuarios.cpp @@ -38,7 +38,7 @@ bool ControladorUsuarios::adicionarUsuario(string nome, string CPF, string ender } -int ControladorUsuarios::registrarEmprestimo(string CPF, DescricaoObra descricao){ +int ControladorUsuarios::registrarEmprestimo(string CPF, DescricaoObra& descricao){ // Search for user auto it = find_if(usuarios.begin(), usuarios.end(), [CPF](Usuario& u) { @@ -60,7 +60,7 @@ int ControladorUsuarios::registrarEmprestimo(string CPF, DescricaoObra descricao } -int ControladorUsuarios::retornarEmprestimo(string CPF, DescricaoObra descricao){ +int ControladorUsuarios::retornarEmprestimo(string CPF, DescricaoObra& descricao){ // Search for user auto it = find_if(usuarios.begin(), usuarios.end(), [CPF](Usuario& u) { diff --git a/sources/ControladorUsuarios.hpp b/sources/ControladorUsuarios.hpp index 72f064ba34401ad8453307d87f04c958ee20801d..f471534d728cc511538beb1993bded03478ca423 100644 --- a/sources/ControladorUsuarios.hpp +++ b/sources/ControladorUsuarios.hpp @@ -20,8 +20,8 @@ class ControladorUsuarios { // Methods bool adicionarUsuario(string nome, string CPF, string endereco, string telefone, string email); - int registrarEmprestimo(string CPF, DescricaoObra descricao); - int retornarEmprestimo(string CPF, DescricaoObra descricao); + int registrarEmprestimo(string CPF, DescricaoObra& descricao); + int retornarEmprestimo(string CPF, DescricaoObra& descricao); int recuperarMultas(string CPF); bool registrarMultaPaga(string CPF, int valor); diff --git a/sources/Emprestimo.cpp b/sources/Emprestimo.cpp index b638d2c29a36ef370bcccbdce0cacabc6217f58b..6ba6c55e932997285a3e3a7b4bdeb5ff4b56db66 100644 --- a/sources/Emprestimo.cpp +++ b/sources/Emprestimo.cpp @@ -6,7 +6,7 @@ using namespace std; // Constructor -Emprestimo::Emprestimo(int data, DescricaoObra descricao) +Emprestimo::Emprestimo(int data, DescricaoObra& descricao) : dataEmprestimo(data), descricao(descricao) {} void Emprestimo::mostraDetalhes() const { diff --git a/sources/Emprestimo.hpp b/sources/Emprestimo.hpp index b8ce99c4b4fc4af41f66b00fc6fcf3b981f36204..f2185e4fc6db7d1ecb3c40969c2df5a2335cbe32 100644 --- a/sources/Emprestimo.hpp +++ b/sources/Emprestimo.hpp @@ -6,12 +6,12 @@ class Emprestimo { private: int dataEmprestimo; - DescricaoObra descricao; + DescricaoObra &descricao; public: // Constructor Emprestimo(); - Emprestimo(int data, DescricaoObra descricao); + Emprestimo(int data, DescricaoObra& descricao); void mostraDetalhes() const; // Methods diff --git a/sources/Usuario.cpp b/sources/Usuario.cpp index e5cb15b288cd7151a130e407e2e62a57733ee134..5ee7565faaffe01b38eac319551dcc02126d7363 100644 --- a/sources/Usuario.cpp +++ b/sources/Usuario.cpp @@ -25,7 +25,7 @@ void Usuario::mostrarDetalhes() const { // Methods -bool Usuario::emprestar(DescricaoObra descricao){ +bool Usuario::emprestar(DescricaoObra& descricao){ // Check number of Borrowed works if (this->emprestimos->size() >= 3) { @@ -44,7 +44,7 @@ bool Usuario::emprestar(DescricaoObra descricao){ return true; } -bool Usuario::devolver(DescricaoObra descricao){ +bool Usuario::devolver(DescricaoObra& descricao){ // Search for Borrowed work auto emp_it = find_if(this->emprestimos->begin(), this->emprestimos->end(), [&descricao](Emprestimo& emp){ @@ -59,7 +59,7 @@ bool Usuario::devolver(DescricaoObra descricao){ emp_it->removeEmprestimo(); // Remove work - this->emprestimos->erase(emp_it); + //this->emprestimos->erase(emp_it); return true; } diff --git a/sources/Usuario.hpp b/sources/Usuario.hpp index f76d9bc67f4f3e70a61a1aa7b749303053f1af64..8447299b21c4433b4d25ba3de3e22deef1907714 100644 --- a/sources/Usuario.hpp +++ b/sources/Usuario.hpp @@ -27,8 +27,8 @@ class Usuario { void mostrarDetalhes() const; // Methods - bool emprestar(DescricaoObra descricao); - bool devolver(DescricaoObra descricao); + bool emprestar(DescricaoObra& descricao); + bool devolver(DescricaoObra& descricao); int atualizarMulta(int valor); // Increase fee string getCPF(); int getMulta(); diff --git a/tdd/obras-test.cpp b/tdd/obras-test.cpp index b5feaf36fd92d32ef0fa4badf3fc7b718922d5be..5c7c894fb4375c9a57de21b7fcf4bd39857736e7 100644 --- a/tdd/obras-test.cpp +++ b/tdd/obras-test.cpp @@ -10,7 +10,7 @@ TEST_CASE("Adicionar Obras") { cout << "> Instanciando o Controlador de Obras" << endl; ControladorObras contObras; - cout << "=> Instanciando um Periodico: " << endl; + cout << "==> Instanciando um Periodico: " << endl; Periodico p("Revista de Ciência", 2023, 5, 3); p.mostrarDetalhes(); cout << endl;