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.
13 changes: 13 additions & 0 deletions Guia3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
__pycache__/
*.pyc
*.pyo
*.pyd
venv/
.venv/
.venv
env/
.env
.pytest_cache/
.pytest_cache
.coverage
htmlcov/
Loading