From ad1063638d3f91f30a68de0c886558e3c9bac88f Mon Sep 17 00:00:00 2001 From: Osmar Felix Date: Thu, 19 Nov 2020 16:11:09 -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..91e682501 --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,2 @@ +class Pessoa(): + pass \ No newline at end of file From 4cb201d642654ed35374c520d9e3af3f36b86a28 Mon Sep 17 00:00:00 2001 From: Osmar Felix Date: Thu, 19 Nov 2020 21:08:57 -0300 Subject: [PATCH 2/6] Criado metodo cumprimentar --- oo/pessoa.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 91e682501..784a18e22 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,2 +1,9 @@ class Pessoa(): - pass \ 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 afb3ad718c0bb525cbe8103095e2de7e44c2cace Mon Sep 17 00:00:00 2001 From: Osmar Felix Date: Sat, 21 Nov 2020 18:34:02 -0300 Subject: [PATCH 3/6] =?UTF-8?q?Criados=20atributos=20de=20inst=C3=A2ncia?= =?UTF-8?q?=20nome=20e=20idade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 784a18e22..7a3d881bc 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,9 +1,19 @@ class Pessoa(): + def __init__(self, nome= None,idade =35): + self.idade = idade + self.nome = nome + + def cumprimentar(self): return f'Olá {id(self)}' + if __name__ == '__main__': - p = Pessoa() + p = Pessoa('Luciano') print(Pessoa.cumprimentar(p)) print(id(p)) - print(p.cumprimentar()) \ No newline at end of file + print(p.cumprimentar()) + print(p.nome) + p.nome = 'Renzo' + print(p.nome) + print(p.idade) \ No newline at end of file From 334652f5ba12f4bbbd01efbed80ccecd85182ade Mon Sep 17 00:00:00 2001 From: Osmar Felix Date: Sat, 21 Nov 2020 18:50:58 -0300 Subject: [PATCH 4/6] Criado atributo complexo filhos --- oo/pessoa.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 7a3d881bc..840b85705 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,7 +1,8 @@ class Pessoa(): - def __init__(self, nome= None,idade =35): + def __init__(self, *filhos, nome=None, idade=35): self.idade = idade self.nome = nome + self.filhos = list(filhos) def cumprimentar(self): @@ -9,11 +10,12 @@ def cumprimentar(self): if __name__ == '__main__': - p = Pessoa('Luciano') - print(Pessoa.cumprimentar(p)) - print(id(p)) - print(p.cumprimentar()) - print(p.nome) - p.nome = 'Renzo' - print(p.nome) - print(p.idade) \ 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) \ No newline at end of file From abba4641506fd1c5df220a2fdce72807689ba4e8 Mon Sep 17 00:00:00 2001 From: Osmar Felix Date: Sat, 21 Nov 2020 19:06:48 -0300 Subject: [PATCH 5/6] =?UTF-8?q?Criado=20e=20removido=20atributo=20=20din?= =?UTF-8?q?=C3=A2mico=20de=20objetos=20do=20tipo=20Pessoa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 840b85705..9d5614643 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -18,4 +18,8 @@ def cumprimentar(self): print(luciano.nome) print(luciano.idade) for filho in luciano.filhos: - print(filho.nome) \ No newline at end of file + print(filho.nome) + luciano.sobrenome = 'Ramalho' + del luciano.filhos + print(luciano.__dict__) + print(renzo.__dict__) \ No newline at end of file From 32493f2133ffebf9ffe90de8ff932f23299010c1 Mon Sep 17 00:00:00 2001 From: Osmar Felix Date: Sat, 21 Nov 2020 19:27:49 -0300 Subject: [PATCH 6/6] Criado atributo de classe olhos --- oo/pessoa.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 9d5614643..a3d0f5355 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,4 +1,5 @@ class Pessoa(): + olhos = 2 def __init__(self, *filhos, nome=None, idade=35): self.idade = idade self.nome = nome @@ -21,5 +22,12 @@ def cumprimentar(self): print(filho.nome) luciano.sobrenome = 'Ramalho' del luciano.filhos + luciano.olhos = 1 + del luciano.olhos print(luciano.__dict__) - print(renzo.__dict__) \ No newline at end of file + print(renzo.__dict__) + Pessoa.olhos = 3 + print(Pessoa.olhos) + print(luciano.olhos) + print(renzo.olhos) + print(id(Pessoa.olhos), id(luciano.olhos), id(renzo.olhos))