redefinir metodo __str__() para mostrar info sobre objectos

This commit is contained in:
2024-09-10 11:56:28 +01:00
parent a6146abc8f
commit 700e79f9ba
3 changed files with 9 additions and 25 deletions

View File

@ -12,6 +12,10 @@ class Mapa:
self.mundo = []
self.dimensao = dimensao
self.mundo = self.inicializar()
self.id_mapa = id(self)
def __str__(self):
return f'Dados Mapa ({self.id_mapa})\n\tdimensao: {self.dimensao[0]} x {self.dimensao[1]}'
def inicializar(self) -> list:
# inicializar mundo