From aa92ce509b64b64df8d7a86535de9059d8a0271b Mon Sep 17 00:00:00 2001 From: neziomunaldi Date: Sat, 18 Jan 2020 11:44:23 -0300 Subject: [PATCH 1/5] Criado o metodo cumprimentar --- oo/pessoa.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 oo/pessoa.py diff --git a/oo/pessoa.py b/oo/pessoa.py new file mode 100644 index 000000000..1cc724214 --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,9 @@ +class Pessoa: + def cumprimentar(self): + return 'Olá! %s' %(id(self)) + +if __name__ == '__main__': + p = Pessoa() + print(Pessoa.cumprimentar(p)) + print(id(p)) + print(p.cumprimentar()) \ No newline at end of file From a738ccd7c55affbe60096d13b60409beda1e2c11 Mon Sep 17 00:00:00 2001 From: neziomunaldi Date: Sat, 18 Jan 2020 11:54:05 -0300 Subject: [PATCH 2/5] Criados os atributos nome e idade --- oo/pessoa.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 1cc724214..6a6bd4634 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,9 +1,16 @@ class Pessoa: + def __init__(self, nome=None, idade=35): + self.idade = idade + self.nome = nome + def cumprimentar(self): return 'Olá! %s' %(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 = 'Nézio' + print(p.nome) \ No newline at end of file From 739c4964951a80ddb48c5db565dbfe7be598ba95 Mon Sep 17 00:00:00 2001 From: neziomunaldi Date: Sat, 18 Jan 2020 12:15:22 -0300 Subject: [PATCH 3/5] Criado atributo complexo filhos --- oo/__init__.py | 0 oo/pessoa.py | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 oo/__init__.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 index 6a6bd4634..21615a074 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,16 +1,19 @@ 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 'Olá! %s' %(id(self)) if __name__ == '__main__': - p = Pessoa('Luciano') - print(Pessoa.cumprimentar(p)) - print(id(p)) - print(p.cumprimentar()) - print(p.nome) - p.nome = 'Nézio' - print(p.nome) \ No newline at end of file + nezio = Pessoa(nome='Nézio') + luciano = Pessoa(nezio, 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 2562a92f9914ae8a6377172fdf225d3391cd528b Mon Sep 17 00:00:00 2001 From: neziomunaldi Date: Sun, 19 Jan 2020 22:31:54 -0300 Subject: [PATCH 4/5] Criado e removido atributo dinamico de objetos do tipo Pessoa --- oo/pessoa.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 21615a074..fe9105443 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -16,4 +16,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(nezio.__dict__) \ No newline at end of file From 190613b16fd962dfcd4d4d0c3ec3d0bb14aa1b51 Mon Sep 17 00:00:00 2001 From: neziomunaldi Date: Sun, 19 Jan 2020 23:21:21 -0300 Subject: [PATCH 5/5] 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 fe9105443..6b24b475b 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 @@ -19,5 +20,12 @@ def cumprimentar(self): print(filho.nome) luciano.sobrenome = 'Ramalho' del luciano.filhos + luciano.olhos = 1 + Pessoa.olhos = 3 + del luciano.olhos print(luciano.__dict__) - print(nezio.__dict__) \ No newline at end of file + print(nezio.__dict__) + print(Pessoa.olhos) + print(luciano.olhos) + print(nezio.olhos) + print(id(Pessoa.olhos), id(luciano.olhos), id(nezio.olhos)) \ No newline at end of file