Skip to content
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
Binary file added Guia1/src/__pycache__/__init__.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 18 additions & 4 deletions Guia1/src/models/record.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
class Record:
def __init__(self, record_id: int, name: str, address: str):
self._id = record_id
self._name = name
self._address = address
try:
id = int(record_id)
except (ValueError, TypeError):
raise ValueError("ID deve ser um número inteiro válido.")

if id <= 0:
raise ValueError("ID inválido.")

if not name or name.strip() == "":
raise ValueError("Nome inválido.Dont can be void")

if not address or address.strip() == "":
raise ValueError("Endereço invalido. Dont can be void")

self._id = id
self._name = name.strip()
self._address = address.strip()

@property
def id(self):
Expand All @@ -17,4 +31,4 @@ def address(self):
return self._address

def __repr__(self):
return f"Record(id={self._id}, name='{self._name}', address='{self._address}')"
return f"Record(id={self._id}, name='{self._name}', address='{self._address}')"
Binary file not shown.
Binary file not shown.
Binary file not shown.
47 changes: 37 additions & 10 deletions Guia1/src/repositories/record_repository.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
import unicodedata

from src.repositories.abstract_repository import AbstractRepository
from src.models.record import Record
from src.utils.file_loader import FileLoader

class RecordRepository(AbstractRepository):

def _normalize_text(text: str) -> str:
normalized = unicodedata.normalize("NFKD", text)
return "".join(ch for ch in normalized if not unicodedata.combining(ch)).lower()


class RecordRepository(AbstractRepository):
def __init__(self, file_path: str):
self._file_path = file_path
self._records = []

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
]
self._records = []
for row in data:
try:
novo_registro = Record(row["id"], row["name"], row["address"])
self._records.append(novo_registro)
except ValueError:
print(
f"Registro inválido ignorado: {{'id': '{row['id']}', 'name': '{row['name']}', 'address': '{row['address']}'}}"
)
continue

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()
]
term = _normalize_text(term)

termos = term.split()

if not termos:
return []

resultados = []

for r in self._records:
palavras_do_registro = (
_normalize_text(r.name).split() + _normalize_text(r.address).split()
)

if all(palavra in palavras_do_registro for palavra in termos):
resultados.append(r)

return resultados
Binary file not shown.
Binary file not shown.
Binary file added Guia1/src/utils/__pycache__/__init__.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file added Guia1/tests/__pycache__/__init__.cpython-314.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 9 additions & 5 deletions Guia1/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import os
import hashlib

class TestRunner:

class TestRunner:
def __init__(self):
base_dir = os.path.dirname(os.path.dirname(__file__))
self.test_file = os.path.join(base_dir, "data", "records_teste.csv")
self.service = RecordService(self.test_file)
print(f"\n{calculate_file_hash(os.path.join(base_dir, "tests", "test_runner.py"))}")
print(
f"\n{calculate_file_hash(os.path.join(base_dir, 'tests', 'test_runner.py'))}"
)

def run(self):
print("\n=== EXECUTANDO TESTES ===")
Expand Down Expand Up @@ -61,7 +63,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 All @@ -70,6 +72,7 @@ def test_search_multiple_terms(self):
except Exception as e:
print(f"FALHA: Erro na busca -> {e}")


def calculate_file_hash(file_path):
try:
hash_md5 = hashlib.md5()
Expand All @@ -83,6 +86,7 @@ def calculate_file_hash(file_path):
except Exception as e:
print(f"Erro ao calcular hash: {e}")
return None



if __name__ == "__main__":
TestRunner().run()
TestRunner().run()
Binary file added Guia2/src/__pycache__/__init__.cpython-314.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.
35 changes: 33 additions & 2 deletions Guia2/src/folha_pagamento/desenvolvedor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,36 @@

# 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)
self.linguagem = linguagem
self.senioridade = senioridade

def calcular_bonus(self):
if self.senioridade == "junior":
bonus = 5 / 100
return self._salario_base * bonus

if self.senioridade == "pleno":
bonus = 10 / 100
return self._salario_base * bonus

if self.senioridade == "senior":
bonus = 15 / 100
return self._salario_base * bonus

def calcular_descontos(self):
return self._salario_base * (8 / 100)

def calcular_adicionais(self):

if self.linguagem == "Python":
return 500
if self.linguagem == "Java":
return 400
if self.linguagem == "JavaScript":
return 350
else:
return 200
24 changes: 22 additions & 2 deletions Guia2/src/folha_pagamento/estagiario.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,25 @@

# 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)
self.curso = curso
self.carga_horaria = carga_horaria

def calcular_bonus(self):
return self._salario_base * (3 / 100)

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

else:
return 350
32 changes: 30 additions & 2 deletions Guia2/src/folha_pagamento/gerente.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,33 @@

# 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)
self.setor = setor
self.qtd_equipe = qtd_equipe

def calcular_bonus(self):

if self.qtd_equipe <= 5:
return self._salario_base * 0.10

elif self.qtd_equipe <= 10:
return self._salario_base * 0.15

if self.qtd_equipe > 10:
return self._salario_base * 0.20

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-314.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions Guia3/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from Guia3.src import *
from Guia3.src import *


def main():
pass


if __name__ == "__main__":
main()
main()
8 changes: 6 additions & 2 deletions Guia3/src/alternativa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from typing import List, Tuple, Dict

class Alternativa:
pass

class Alternativa: # it mean that might to be String or nada
def __init__(self, texto: str, correta: bool, explicacao: str = None):
self.texto = texto
self.correta = correta
self.explicacao = explicacao
22 changes: 20 additions & 2 deletions Guia3/src/pergunta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
from typing import List, Tuple, Dict
from abc import ABC, abstractmethod

class Pergunta:
pass

class Pergunta(ABC):
def __init__(self, texto: str, explicacao_geral: str = None):
self._texto = texto
self._explicacao_geral = explicacao_geral

@property
def texto(self):
return self._texto

@abstractmethod
def validar_resposta(self, resposta) -> bool:
pass

def get_explicacao(self) -> str:
return self._explicacao_geral

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

class PerguntaDiscursiva:
pass

class PerguntaDiscursiva(Pergunta):
def __init__(
self,
texto,
resposta_esperada=None,
explicacao_geral: str = None,
case_sensitive: bool = False,
):
super().__init__(texto, explicacao_geral)
self._resposta_esperada = resposta_esperada
self._case_sensitive = case_sensitive

@property
def resposta_esperada(self):
return self._resposta_esperada

def validar_resposta(self, texto: str) -> bool:

if self._resposta_esperada is None:
return

if not self._case_sensitive:
resposta_lower = self._resposta_esperada
return resposta_lower.lower() == texto.lower()

return self._resposta_esperada == texto

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

class PerguntaMultiplaEscolha:
pass

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

@property
def alternativa(self):
return self._alternativa

def validar_resposta(self, indice: int) -> bool:
v = self._alternativa[indice]
return v.correta

def get_alternativa_correta(self) -> Alternativa:
for i in self._alternativa:
if i.correta is True:
return i

def get_tipo(self):
return "multipla_escolha"

def get_explicacao(self):
return "Python normalmente é interpretada."
22 changes: 21 additions & 1 deletion Guia3/src/questionario.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
from typing import List, Tuple, Dict
from src.pergunta import Pergunta
from src.tentativaquestionario import TentativaQuestionario


class Questionario:
pass
def __init__(self, titulo: str):
self._titulo = titulo
self._perguntas = []

@property
def titulo(self):
return self._titulo

@property
def perguntas(self):
return self._perguntas

def adicionar_pergunta(self, p: Pergunta):
self._perguntas.append(p)

def criar_attempt(self, usuario: str) -> TentativaQuestionario:
t = TentativaQuestionario(questionario=self, usuario=usuario)
return t
Loading