From e7a0300d2519f8dc5b8cb7586283d1589f6347f3 Mon Sep 17 00:00:00 2001 From: MATHIAS Date: Wed, 22 Jan 2020 21:49:54 -0300 Subject: [PATCH 1/5] Criada 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..e1da50e22 --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,2 @@ +class Pessoa: + pass \ No newline at end of file From 0aca712d5e1346900eba99394fd69e57726db3a9 Mon Sep 17 00:00:00 2001 From: MATHIAS Date: Wed, 22 Jan 2020 22:21:22 -0300 Subject: [PATCH 2/5] =?UTF-8?q?Criado=20m=C3=A9todo=20cumprimentar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index e1da50e22..923520597 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 c6faf2e1b2ed5a4e4e57950eeabb36aa7cc12df8 Mon Sep 17 00:00:00 2001 From: MATHIAS Date: Wed, 22 Jan 2020 22:36:23 -0300 Subject: [PATCH 3/5] Criado atriutos de dados nome e idade --- oo/pessoa.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 923520597..b5c8df319 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('Mathias', 40) print(Pessoa.cumprimentar(p)) print(id(p)) - print(p.cumprimentar()) \ No newline at end of file + print(p.cumprimentar()) + print(p.nome) + print(p.idade) + p.nome = 'teste' + print(p.nome) \ No newline at end of file From e8f4fae9298a218638b51d9484e3a93ba9eb31d6 Mon Sep 17 00:00:00 2001 From: MATHIAS Date: Thu, 23 Jan 2020 20:01:09 -0300 Subject: [PATCH 4/5] Criado um atributo complexo --- oo/pessoa.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index b5c8df319..664905bc7 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,17 +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 f'Olá {id(self)}' if __name__ == '__main__': - p = Pessoa('Mathias', 40) - print(Pessoa.cumprimentar(p)) - print(id(p)) - print(p.cumprimentar()) - print(p.nome) - print(p.idade) - p.nome = 'teste' - print(p.nome) \ No newline at end of file + filho1 = Pessoa(nome='Ana Laura') + filho2 = Pessoa(nome='Bernardo') + mathias = Pessoa(filho1, filho2, nome='Mathias') + print(Pessoa.cumprimentar(mathias)) + print(mathias.nome) + print(mathias.idade) + + for filho in mathias.filhos: + print(filho.nome) From 2d08945667aa38dd91a0734e4b436d38ec00bcb5 Mon Sep 17 00:00:00 2001 From: MATHIAS Date: Thu, 23 Jan 2020 20:35:41 -0300 Subject: [PATCH 5/5] =?UTF-8?q?Criado=20e=20removido=20atributo=20din?= =?UTF-8?q?=C3=A2mico=20de=20objeto=20do=20tipo=20pessoa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/oo/pessoa.py b/oo/pessoa.py index 664905bc7..1127ec8e9 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -17,3 +17,10 @@ def cumprimentar(self): for filho in mathias.filhos: print(filho.nome) + mathias.sobrenome='Assis' + del mathias.filhos + del mathias.sobrenome + del filho1.filhos + print(mathias.__dict__) + print(filho1.__dict__) +