From 00173f083812ce445c1b25243f97ed6d06173781 Mon Sep 17 00:00:00 2001 From: joaquil Date: Tue, 31 Mar 2020 13:48:29 -0300 Subject: [PATCH 1/5] Criada a classe pessoa.py --- 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..e1da50e22 --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,2 @@ +class Pessoa: + pass \ No newline at end of file From cc72ef053e9c281f3d0f3b9c892898d264eb3e23 Mon Sep 17 00:00:00 2001 From: joaquil Date: Wed, 1 Apr 2020 10:56:39 -0300 Subject: [PATCH 2/5] =?UTF-8?q?Criada=20a=20classe=20pessoa.py=20Criado=20?= =?UTF-8?q?o=20m=C3=A9todo=20cumprimentar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index e1da50e22..5d0714f1f 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,2 +1,9 @@ -class Pessoa: - pass \ No newline at end of file +class Pessoa(): + 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 1331a193b41e324006f8bbc666fed12b863950c7 Mon Sep 17 00:00:00 2001 From: joaquil Date: Sat, 4 Apr 2020 09:25:50 -0300 Subject: [PATCH 3/5] =?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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 5d0714f1f..403b7aeec 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,9 +1,17 @@ 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('Vera') print(Pessoa.cumprimentar(p)) print(id(p)) - print(p.cumprimentar()) \ No newline at end of file + print(p.cumprimentar()) + print(p.nome) + p.nome = 'Joaquim' + print(p.nome) + print(p.idade) \ No newline at end of file From 0399880ba4d8ba1f842e323213ec778bd777876b Mon Sep 17 00:00:00 2001 From: joaquil Date: Sat, 4 Apr 2020 10:39:19 -0300 Subject: [PATCH 4/5] =?UTF-8?q?Criado=20e=20removido=20atributo=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 | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 403b7aeec..1b9b47cc7 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,17 +1,26 @@ 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): - return f'Olá {id(self)}' + return f'Olá {self.nome} {id(self)}' + if __name__ == '__main__': - p = Pessoa('Vera') - print(Pessoa.cumprimentar(p)) - print(id(p)) - print(p.cumprimentar()) - print(p.nome) - p.nome = 'Joaquim' - 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(Pessoa.cumprimentar(renzo)) + 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(luciano.__dict__) + print(renzo.__dict__) + From 7c9b56016cee6851ef5024328a1d1c6e826915fa Mon Sep 17 00:00:00 2001 From: joaquil Date: Sat, 4 Apr 2020 11:47:03 -0300 Subject: [PATCH 5/5] Criado atributo de classe ohos --- oo/pessoa.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 1b9b47cc7..97a8b1fc8 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,4 +1,6 @@ class Pessoa(): + olhos = 2 + def __init__(self, *filhos, nome=None, idade=35): self.idade = idade self.nome = nome @@ -21,6 +23,11 @@ def cumprimentar(self): print(filho.nome) luciano.sobrenome = 'Ramalho' del luciano.filhos + luciano.olhos = 1 print(luciano.__dict__) print(renzo.__dict__) - + Pessoa.olhos = 3 + print(Pessoa.olhos) + print(renzo.olhos) + print(luciano.olhos) + print(id(Pessoa.olhos), id(renzo.olhos), id(luciano.olhos))