From ccce42faceb87c1b6ad4222355628dad5b01b302 Mon Sep 17 00:00:00 2001 From: helter Date: Sun, 22 Mar 2020 18:25:07 -0300 Subject: [PATCH 1/6] Criada a classe Pessoa --- oo/__init__.py | 0 oo/pessoa.py | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 oo/__init__.py create mode 100644 oo/pessoa.py diff --git a/oo/__init__.py b/oo/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/oo/pessoa.py b/oo/pessoa.py new file mode 100644 index 000000000..93f28ad1b --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,2 @@ +class Pessoa: + \ No newline at end of file From 1cd202a27807003f4236f106fb8cf81ffc8843b8 Mon Sep 17 00:00:00 2001 From: helter Date: Sun, 22 Mar 2020 18:47:37 -0300 Subject: [PATCH 2/6] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20na=20classe=20Pesso?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 93f28ad1b..a4ddf609a 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,2 +1,10 @@ class Pessoa: - \ No newline at end of file + def cumprimentar(self): + return f'Olá {id(self)}' + + +if __name__ == '__main__': + p = Pessoa() + print(Pessoa.cumprimentar(p)) + print(id(p)) + print(p.cumprimentar()) \ No newline at end of file From 9a94ad4985c2a98fc58083d2658fef7e6a6b4f62 Mon Sep 17 00:00:00 2001 From: helter Date: Tue, 24 Mar 2020 15:43:47 -0300 Subject: [PATCH 3/6] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20na=20classe=20Pesso?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index a4ddf609a..d444cd2cd 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,10 +1,22 @@ class Pessoa: + def __init__(self, *filhos, nome=None, idade=25): + self.idade = idade + self.nome = nome + self.filhos = list(filhos) def cumprimentar(self): return f'Olá {id(self)}' - if __name__ == '__main__': - p = Pessoa() - print(Pessoa.cumprimentar(p)) - print(id(p)) - print(p.cumprimentar()) \ No newline at end of file + renzo = Pessoa(nome='Renzo') + luciano = Pessoa(renzo, nome='Luciano') + print(Pessoa.cumprimentar(luciano)) + print(id(luciano)) + print(luciano.cumprimentar()) + print(luciano.nome) + print(luciano.idade) + for filho in luciano.filhos: + print(filho.nome) + luciano.sobrenome = 'Ramalho' + del luciano.filhos + print(renzo.__dict__) + print(luciano.__dict__) \ No newline at end of file From c8e3f9d6a4d8978fbe5397643e9fa0dc94a06e66 Mon Sep 17 00:00:00 2001 From: helter Date: Sun, 29 Mar 2020 18:26:36 -0300 Subject: [PATCH 4/6] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20na=20classe=20Pesso?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/carro.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 oo/carro.py diff --git a/oo/carro.py b/oo/carro.py new file mode 100644 index 000000000..bace3afd4 --- /dev/null +++ b/oo/carro.py @@ -0,0 +1,31 @@ +NORTE = 'Norte' +LESTE = 'Leste' +SUL = 'Sul' +OESTE = 'Oeste' + +class Direcao: + rotacao_a_direita_dct = { + NORTE : LESTE, LESTE : SUL, SUL : OESTE, OESTE : NORTE + } + rotacao_a_esquerda_dct = { + NORTE : OESTE, LESTE : NORTE, SUL : OESTE, OESTE : NORTE + } + def __init__(self): + self.valor = NORTE + + def girar_a_direita(self): + self.valor = self.rotacao_a_direita_dct[self.valor] + + def girar_a_es(self): + self.valor = self.rotacao_a_esquerda_dct[self.valor] + +class Motor: + def __init__(self): + self.velocidade = 0 + + def acelerar(self): + self.velocidade += 1 + + def frear(self): + self.velocidade -= 2 + self.velocidade = max(0, self.velocidade) From 22183c79dc52552374858cbb10955229931de9b8 Mon Sep 17 00:00:00 2001 From: helter Date: Sun, 29 Mar 2020 18:56:02 -0300 Subject: [PATCH 5/6] =?UTF-8?q?Finaliza=C3=A7=C3=A3o=20do=20carro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/carro.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/oo/carro.py b/oo/carro.py index bace3afd4..dafded51a 100644 --- a/oo/carro.py +++ b/oo/carro.py @@ -1,3 +1,18 @@ +class Carro: + def __init__(self, direcao, motor): + self.motor = motor + self.direcao = direcao + def calcular_velocidade(self): + return self.motor.velocidade + def acelerar(self): + return self.motor.acelerar() + def frear(self): + return self.motor.frear() + def girar_a_direita(self): + self.direcao.girar_a_direita() + def girar_a_es(self): + self.direcao.girar_a_es() + NORTE = 'Norte' LESTE = 'Leste' SUL = 'Sul' @@ -29,3 +44,4 @@ def acelerar(self): def frear(self): self.velocidade -= 2 self.velocidade = max(0, self.velocidade) + From f9a9de20d84dd2ceedd6d8a9af1a2526d8d56718 Mon Sep 17 00:00:00 2001 From: helter Date: Mon, 30 Mar 2020 00:51:58 -0300 Subject: [PATCH 6/6] Estudando framework unittest --- oo/teste_carro.py | 7 +++++++ testes/{atores_testes.py => testes_atores.py} | 0 testes/{fase_testes.py => testes_fase.py} | 0 testes/{integracao.py => testes_integracao.py} | 0 4 files changed, 7 insertions(+) create mode 100644 oo/teste_carro.py rename testes/{atores_testes.py => testes_atores.py} (100%) rename testes/{fase_testes.py => testes_fase.py} (100%) rename testes/{integracao.py => testes_integracao.py} (100%) diff --git a/oo/teste_carro.py b/oo/teste_carro.py new file mode 100644 index 000000000..f7640bd9d --- /dev/null +++ b/oo/teste_carro.py @@ -0,0 +1,7 @@ +from unittest import TestCase +from oo.carro import Motor + +class CarroTesteCase(TestCase): + def teste_velocidade_inicial(self): + motor=Motor() + self.assertEqual(0, motor.velocidade) \ No newline at end of file diff --git a/testes/atores_testes.py b/testes/testes_atores.py similarity index 100% rename from testes/atores_testes.py rename to testes/testes_atores.py diff --git a/testes/fase_testes.py b/testes/testes_fase.py similarity index 100% rename from testes/fase_testes.py rename to testes/testes_fase.py diff --git a/testes/integracao.py b/testes/testes_integracao.py similarity index 100% rename from testes/integracao.py rename to testes/testes_integracao.py