From 6b77de8ea3e069aea33ac7dae70b09e850e83bf7 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 17 Jun 2022 15:25:57 -0300 Subject: [PATCH 1/7] =?UTF-8?q?cria=C3=A7=C3=A3o=20modulo=20orienta=C3=A7?= =?UTF-8?q?=C3=A3o=20a=20objeto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 oo/__init__.py diff --git a/oo/__init__.py b/oo/__init__.py new file mode 100644 index 000000000..e69de29bb From 4e276f0b33d7ed2873ba47cbffa9504997878a75 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 17 Jun 2022 15:50:07 -0300 Subject: [PATCH 2/7] =?UTF-8?q?cria=C3=A7=C3=A3o=20classe=20pessoa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oo/pessoa.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 oo/pessoa.py 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 f38bf248e94055169275a1aab3af2bcbd9e6f54f Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 17 Jun 2022 16:23:59 -0300 Subject: [PATCH 3/7] =?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 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index e1da50e22..4449ab782 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,2 +1,13 @@ -class Pessoa: - pass \ No newline at end of file +""" +Aula sobre Métodos +""" + +class Pessoa:#classe + def cumprimentar(self):# método = função que pertence a uma classe + return f"Olá! {id(self)}" + +if __name__ == '__main__': ##este é o teste da classe + p = Pessoa() #objeto + print(Pessoa.cumprimentar(p)) + print(id(p)) + print(p.cumprimentar()) \ No newline at end of file From 83a580a680a1eb8cf6b5503229fcd9f3935492ad Mon Sep 17 00:00:00 2001 From: Igor Date: Sat, 18 Jun 2022 21:43:24 -0300 Subject: [PATCH 4/7] =?UTF-8?q?Criados=20atributos=20e=20inst=C3=A2ncia=20?= =?UTF-8?q?nome=20e=20idade?= 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 4449ab782..f4d316022 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -3,6 +3,10 @@ """ class Pessoa:#classe + def __init__(self, nome=None, idade=39): + self.idade = idade + self.nome = nome + def cumprimentar(self):# método = função que pertence a uma classe return f"Olá! {id(self)}" @@ -10,4 +14,8 @@ def cumprimentar(self):# método = função que pertence a uma classe p = Pessoa() #objeto print(Pessoa.cumprimentar(p)) print(id(p)) - print(p.cumprimentar()) \ No newline at end of file + print(p.cumprimentar()) + print(p.nome) + p.nome = "Igor" + print(p.nome, p.idade) + \ No newline at end of file From 899591817d1e008ecdc265b883ec0fd23faa850b Mon Sep 17 00:00:00 2001 From: Igor Date: Sat, 18 Jun 2022 22:36:52 -0300 Subject: [PATCH 5/7] criado atributo complexo filhos --- oo/pessoa.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index f4d316022..9b87d602e 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -3,19 +3,22 @@ """ class Pessoa:#classe - def __init__(self, nome=None, idade=39): + def __init__(self, *filhos, nome=None, idade=39): self.idade = idade self.nome = nome + self.filhos = list(filhos) def cumprimentar(self):# método = função que pertence a uma classe return f"Olá! {id(self)}" if __name__ == '__main__': ##este é o teste da classe - p = Pessoa() #objeto - print(Pessoa.cumprimentar(p)) - print(id(p)) - print(p.cumprimentar()) - print(p.nome) - p.nome = "Igor" - print(p.nome, p.idade) - \ No newline at end of file + renzo = Pessoa(nome='Renzo') #objeto + luciano = Pessoa(renzo, nome='Luciano',idade=50) #objeto + 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 8bcca3a3b9ece52a87e1c8a2a024552e5826eb37 Mon Sep 17 00:00:00 2001 From: Igor Date: Sat, 18 Jun 2022 23:05:59 -0300 Subject: [PATCH 6/7] =?UTF-8?q?criado=20e=20removido=20atributo=20=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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/oo/pessoa.py b/oo/pessoa.py index 9b87d602e..aa0ed5e36 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -14,11 +14,21 @@ def cumprimentar(self):# método = função que pertence a uma classe if __name__ == '__main__': ##este é o teste da classe renzo = Pessoa(nome='Renzo') #objeto luciano = Pessoa(renzo, nome='Luciano',idade=50) #objeto + 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(luciano.__dict__) + print(renzo.__dict__) + \ No newline at end of file From 52e6e8693581e2045a3ec18e0b5c2a560b184848 Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 22 Jun 2022 15:36:26 -0300 Subject: [PATCH 7/7] criado atributo de classe olhos --- oo/pessoa.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index aa0ed5e36..50e273f2d 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -3,6 +3,8 @@ """ class Pessoa:#classe + olhos = 2 + def __init__(self, *filhos, nome=None, idade=39): self.idade = idade self.nome = nome @@ -27,8 +29,16 @@ def cumprimentar(self):# método = função que pertence a uma classe luciano.sobrenome = "Ramalho" del luciano.filhos - + luciano.olhos = 1 + del luciano.olhos print(luciano.__dict__) print(renzo.__dict__) - - \ No newline at end of file + Pessoa.olhos = 3 + '''. + __dict__ é um atributo python que revela todos + os atribuitos de instância de uma função + ''' + print(Pessoa.olhos) + print(luciano.olhos) + print(renzo.olhos) + print(id(Pessoa.olhos), id(luciano.olhos), id(renzo.olhos)) \ No newline at end of file