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

Branch acervo #22

Open
wants to merge 9 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
59 changes: 59 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"condition_variable": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"ratio": "cpp",
"set": "cpp",
"string": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp"
},
"C_Cpp.errorSquiggles": "disabled"
}
33 changes: 24 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
CC := g++
SRCDIR := src
BUILDDIR := build
TARGET := main
TSTDIR := tests
OBJDIR := build
BINDIR := bin

MAIN := program/main.cpp
TESTER := program/tester.cpp

SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
CFLAGS := -g -Wall -O3 -std=c++20
INC := -I include/ -I third_party/
OBJECTS := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
TSTSOURCES := $(shell find $(TSTDIR) -type f -name *.$(SRCEXT))

$(TARGET): $(OBJECTS)
$(CC) $^ -o $(TARGET)
# -g debug, --coverage cobertura
CFLAGS := -g --coverage -Wall -O3 -std=c++20
INC := -I include/ -I third_party/

$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
$(OBJDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<

main: $(OBJECTS)
@mkdir -p $(BINDIR)
$(CC) $(CFLAGS) $(INC) $(MAIN) $^ -o $(BINDIR)/main

tests: $(OBJECTS)
@mkdir -p $(BINDIR)
$(CC) $(CFLAGS) $(INC) $(TESTER) $(TSTSOURCES) $^ -o $(BINDIR)/tester
$(BINDIR)/tester

all: main

clean:
$(RM) -r $(BUILDDIR)/* $(TARGET)
$(RM) -r $(OBJDIR)/* $(BINDIR)/* coverage/* *.gcda *.gcno

.PHONY: clean
Binary file removed bin/tester
Binary file not shown.
50 changes: 35 additions & 15 deletions include/acervo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,53 @@
#include <string>

using namespace std;

/**
* @brief Classe Acervo, base
*/
class Acervo {

private:
string autor;
int anoPublicacao;
string titulo;
string genero;
int codigo;

public:
//Construtor
/**
* @brief Construtor da classe
*/
Acervo(string autor, int anoPublicacao, string titulo, string genero, int codigo);
virtual ~Acervo();

//getters
/**
* @brief Pega o autor
*/
string getAutor() const;

/**
* @brief Pega o ano de publicação
*/
int getAnoPublicacao() const;

/**
* @brief Pega o Título
*/
string getTitulo() const;

/**
* @brief Pega o Gênero
*/
string getGenero() const;
int getCodigo() const;

//setters
/*string setAutor() const;
int setAnoPublicacao() const;
string setTitulo() const;
string setGenero() const;
int setCodigo() const;*/
/**
* @brief Pega o código
*/
int getCodigo() const;

virtual ~Acervo();

private:
string autor;
int anoPublicacao;
string titulo;
string genero;
int codigo;
};

#endif // ACERVO_H
68 changes: 56 additions & 12 deletions include/exemplar.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,71 @@


class Exemplar : public Acervo {

private:
bool emprestado;
int dataEmprestimo;
int codigoEspecifico;
int multa;

public:
Exemplar(std::string autor, int anoPublicacao, std::string titulo, std::string genero, float codigo,
bool emprestado, int dataAquisicao, int codigoEspecifico, int dataDevolucao);

/**
* @brief Construtor da classe
*/
Exemplar(std::string autor, int anoPublicacao, std::string titulo, std::string genero, int codigo,
bool emprestado, int codigoEspecifico);


// Métodos getters
bool isEmprestado() const;
int getDataAquisicao() const;
/**
* @brief Verifica se o exemplar está emprestado.
*/
bool isEmprestado();

/**
* @brief Pega a data de empréstimo do exemplar.
*/
int getdataEmprestimo() const;

/**
* @brief Obtém o código específico do exemplar.
*/
int getCodigoEspecifico() const;

/**
* @brief Pega a data de devolução do exemplar.
*/
int getDataDevolucao() const;

/**
* @brief Pega o valor da multa que foi calculado no calculaMulta
*/
int getMulta();

/**
* @brief Define a data de empréstimo do exemplar.
* //set -> Este set é necessário para realizar os test cases
*/
//set
void setDataEmprestimo(int dataEmprestimo);



//métodos
//void mostraMulta(int dataAtual) const;
int calculaMulta();
int calculaDataDevolucao();
/**
* @brief Calcula a data de devolução do exemplar, com base em 1 mês após a data de emprestimo
*/
int calculaDataDevolucaoSistema();

/**
* @brief Calcula a multa do exemplar com base na data de devolução e nos dias passados apos a devolução estipulada no sistema
*/
void calculaMulta();

private:
bool emprestado;
int dataAquisicao;
int codigoEspecifico;
int dataDevolucao;

~Exemplar();


};

Expand Down
6 changes: 4 additions & 2 deletions src/acervo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Acervo::Acervo(std::string autor, int anoPublicacao, std::string titulo, std::st
: autor(autor), anoPublicacao(anoPublicacao), titulo(titulo), genero(genero), codigo(codigo) {
}

Acervo::~Acervo() {
}


std::string Acervo::getAutor() const {
return autor;
Expand All @@ -25,4 +24,7 @@ std::string Acervo::getGenero() const {

int Acervo::getCodigo() const {
return codigo;
}

Acervo::~Acervo() {
}
Loading