Skip to content

Commit f52c670

Browse files
committed
Criado atributo complexo filhos
1 parent f19af56 commit f52c670

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

oo/pessoa.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
class Pessoa:
22

3-
def __init__(self, nome=None, idade=51):
3+
def __init__(self, *filhos, nome=None, idade=51):
44
self.idade = idade
55
self.nome = nome
6+
self.filhos = list(filhos)
67

78
def cumprimentar(self):
89
return f'Olá {id(self)}'
910

1011
if __name__ == '__main__':
11-
p = Pessoa('Joao')
12-
print(Pessoa.cumprimentar(p))
13-
print(id(p))
14-
print(p.cumprimentar())
15-
print(p.nome)
16-
p.nome='Jotapê'
17-
print(p.nome)
12+
renzo = Pessoa(nome='Renzo')
13+
luciano = Pessoa(renzo, nome='Luciano')
14+
print(Pessoa.cumprimentar(luciano))
15+
print(id(luciano))
16+
print(luciano.cumprimentar())
17+
print(luciano.nome)
18+
print(luciano.idade)
19+
for filho in luciano.filhos:
20+
print(filho.nome)

0 commit comments

Comments
 (0)