Skip to content
Binary file added Guia1/src/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file added Guia1/src/__pycache__/main.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 20 additions & 9 deletions Guia1/src/repositories/record_repository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from src.repositories.abstract_repository import AbstractRepository
from src.models.record import Record
from src.utils.file_loader import FileLoader
from unidecode import unidecode

class RecordRepository(AbstractRepository):

Expand All @@ -10,15 +11,25 @@ def __init__(self, file_path: str):

def load_all(self):
data = FileLoader.load_csv(self._file_path)
self._records = [
Record(int(row["id"]), row["name"], row["address"])
for row in data
]
for row in data:
try:
id = int(row['id'])
if row['name'].strip() == '' or row['address'].strip() == '' or id < 0:
raise ValueError()
else:
self._records.append(Record(id, row['name'], row['address']))
except:
print(f"Registro inválido ignorado {row}")

return self._records

def search(self, term: str):
term = term.lower()
return [
r for r in self._records
if term in r.name.lower() or term in r.address.lower()
]
terms = unidecode(term).lower().split()
results = []

for r in self._records:
nome = unidecode(r.name).lower()
add = unidecode(r.address).lower()
if all(palavra in nome or palavra in add for palavra in terms):
results.append(r)
return results
Binary file not shown.
Binary file not shown.
Binary file added Guia1/src/utils/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file added Guia1/tests/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Guia1/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_search_multiple_terms(self):

for r in results:
text = (r.name + " " + r.address).lower()
if "joao" not in text or "rua" not in text or "a" not in text:
if "joão" not in text or "rua" not in text or "a" not in text:
print("FALHA: Resultado incorreto na busca")
return

Expand Down
Binary file added Guia2/src/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 34 additions & 2 deletions Guia2/src/folha_pagamento/desenvolvedor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,37 @@

# Desenvolva a classe Desenvolvedor aqui.

class Desenvolvedor:
pass
class Desenvolvedor(Funcionario):
def __init__(self, nome, matricula, salario_base, linguagem, senioridade):
super().__init__(nome, matricula, salario_base)
if not linguagem:
raise ValueError("Sem valor")
if not senioridade:
raise ValueError("Sem valor")
self.linguagem = linguagem.strip()
self.senioridade = senioridade.strip()

def calcular_bonus(self):
if self.senioridade == "junior":
return self.salario_base * 0.05
elif self.senioridade == "pleno":
return self.salario_base * 0.1
elif self.senioridade == "senior":
return self.salario_base * 0.15

def calcular_descontos(self):
return self.salario_base * 0.08

def calcular_adicionais(self):
if self.linguagem == "Python":
return 500
elif self.linguagem == "Java":
return 400
elif self.linguagem == "JavaScript":
return 350
else:
return 200




25 changes: 23 additions & 2 deletions Guia2/src/folha_pagamento/estagiario.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,26 @@

# Desenvolva a classe Estagiario aqui.

class Estagiario:
pass
class Estagiario(Funcionario):
def __init__(self, nome, matricula, salario_base, curso, carga_horaria):
super().__init__(nome, matricula, salario_base)
if not curso:
raise ValueError("Sem valor")
if not carga_horaria or carga_horaria <= 0:
raise ValueError("Sem valor ou valor incorreto")
self.curso = curso
self.carga_horaria = carga_horaria

def calcular_bonus(self):
return self.salario_base * 0.03

def calcular_descontos(self):
return self.salario_base * 0.02

def calcular_adicionais(self):
if self.carga_horaria <= 20:
return 150
elif self.carga_horaria <= 30:
return 250
elif self.carga_horaria <= 40:
return 350
31 changes: 29 additions & 2 deletions Guia2/src/folha_pagamento/gerente.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,32 @@

# Desenvolva a classe Gerente aqui.

class Gerente:
pass
class Gerente(Funcionario):
def __init__(self, nome, matricula, salario_base, setor, qtd_equipe):
super().__init__(nome, matricula, salario_base)
if not setor:
raise ValueError("Sem valor")
if not qtd_equipe or qtd_equipe <= 0:
raise ValueError("Sem valor ou valor incorreto")
self.setor = setor
self.qtd_equipe = qtd_equipe

def calcular_bonus(self):
if self.qtd_equipe <= 5:
return self.salario_base * 0.1
elif self.qtd_equipe > 5 and self.qtd_equipe <= 10:
return self.salario_base * 0.15
elif self.qtd_equipe > 10:
return self.salario_base * 0.2

def calcular_descontos(self):
return self.salario_base * 0.12

def calcular_adicionais(self):

if self.qtd_equipe > 10:
return 2000
elif self.qtd_equipe > 5:
return 1000
else:
return 500
Binary file added Guia2/tests/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file added Guia2/tests/__pycache__/integrity.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions Guia2/tests/integrity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@



from pathlib import Path
import hashlib

Expand Down
8 changes: 7 additions & 1 deletion Guia3/src/alternativa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from typing import List, Tuple, Dict

class Alternativa:
pass
def __init__(self, texto, correta, explicacao = None):
self.texto = texto
self.correta = correta
self.explicacao = explicacao

def get_correta(self):
return self.correta
18 changes: 16 additions & 2 deletions Guia3/src/pergunta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
from typing import List, Tuple, Dict
from abc import ABC, abstractmethod

class Pergunta:
pass
class Pergunta(ABC):
def __init__(self, texto, explicacao_geral=None):
self.texto = texto
self.explicacao_geral = explicacao_geral

@abstractmethod
def validar_resposta(self, resposta):
pass

def get_explicacao(self):
return self.explicacao_geral

@abstractmethod
def get_tipo(self):
pass
17 changes: 15 additions & 2 deletions Guia3/src/perguntadiscursiva.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
from typing import List, Tuple, Dict
from .pergunta import Pergunta

class PerguntaDiscursiva:
pass
class PerguntaDiscursiva(Pergunta):
def __init__(self, texto, resposta_esperada=None, case_sensitive=True):
super().__init__(texto)
self.resposta_esperada = resposta_esperada
self.case_sensitive = case_sensitive

def validar_resposta(self, res):
if res == self.resposta_esperada:
return True
else:
return False

def get_tipo(self):
return "discursiva"
23 changes: 21 additions & 2 deletions Guia3/src/perguntamultiplaescolha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
from typing import List, Tuple, Dict
from .pergunta import Pergunta

class PerguntaMultiplaEscolha:
pass
class PerguntaMultiplaEscolha(Pergunta):
def __init__(self, texto, alternativas, explicacao_geral=None):
super().__init__(texto, explicacao_geral)
self.alternativas = alternativas

def validar_resposta(self, indice):
resposta = self.alternativas[indice]
return resposta.get_correta()

def get_alternativa_correta(self):
for res in self.alternativas:
if res.get_correta() == True:
return res

def get_tipo(self):
return "multipla_escolha"

def get_explicacao(self):
return self.explicacao_geral

12 changes: 11 additions & 1 deletion Guia3/src/questionario.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
from typing import List, Tuple, Dict
from .tentativaquestionario import TentativaQuestionario

class Questionario:
pass
def __init__(self, titulo):
self.titulo = titulo
self.perguntas = []

def adicionar_pergunta(self, pergunta):
self.perguntas.append(pergunta)

def criar_attempt(self, usuario):
return TentativaQuestionario(self, usuario)

15 changes: 13 additions & 2 deletions Guia3/src/resposta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
from typing import List, Tuple, Dict
from abc import ABC, abstractmethod

class Resposta:
pass
class Resposta(ABC):
def __init__(self, pergunta):
self.pergunta = pergunta

@property
@abstractmethod
def esta_correta(self):
pass

@abstractmethod
def calcular_pontuacao(self):
pass
14 changes: 12 additions & 2 deletions Guia3/src/respostadiscursiva.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
from typing import List, Tuple, Dict
from .resposta import Resposta

class RespostaDiscursiva:
pass
class RespostaDiscursiva(Resposta):
def __init__(self, pergunta, texto_resposta):
super().__init__(pergunta)
self.texto_resposta = texto_resposta

@property
def esta_correta(self):
return self.pergunta.validar_resposta(self.texto_resposta)

def calcular_pontuacao(self):
return 1.0 if self.esta_correta else 0.0
14 changes: 12 additions & 2 deletions Guia3/src/respostaobjetiva.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
from typing import List, Tuple, Dict
from .resposta import Resposta

class RespostaObjetiva:
pass
class RespostaObjetiva(Resposta):
def __init__(self, pergunta, indice_escolhido):
super().__init__(pergunta)
self.indice_escolhido = indice_escolhido

@property
def esta_correta(self):
return self.pergunta.validar_resposta(self.indice_escolhido)

def calcular_pontuacao(self):
return 1.0 if self.esta_correta else 0.0
33 changes: 31 additions & 2 deletions Guia3/src/tentativaquestionario.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
from typing import List, Tuple, Dict
from datetime import datetime
from .respostaobjetiva import RespostaObjetiva
from .respostadiscursiva import RespostaDiscursiva
from .perguntamultiplaescolha import PerguntaMultiplaEscolha
from .perguntadiscursiva import PerguntaDiscursiva

class TentativaQuestionario:
pass
def __init__(self, questionario, usuario):
self.questionario = questionario
self.usuario = usuario
self.data_inicio = datetime.now()
self.data_fim = None
self.respostas = []

def registrar_resposta(self, indice_pergunta, valor):
pergunta = self.questionario.perguntas[indice_pergunta]
if isinstance(pergunta, PerguntaMultiplaEscolha):
resposta = RespostaObjetiva(pergunta, valor)
else:
resposta = RespostaDiscursiva(pergunta, valor)
self.respostas.append(resposta)

def calcular_pontuacao(self):
return sum(r.calcular_pontuacao() for r in self.respostas)

def finalizar(self):
self.data_fim = datetime.now()
pontuacao = self.calcular_pontuacao()
feedback = f"Pontuação final: {pontuacao}"
return pontuacao, feedback

def is_finalizado(self):
return self.data_fim is not None
Binary file added Guia4.zip
Binary file not shown.
Loading