forked from SVIG/python-bootcamp
19 lines
577 B
Python
19 lines
577 B
Python
from Simulation import Simulation
|
|
class Vault:
|
|
def __init__(self):
|
|
self._treasure = "gold"
|
|
self._attributes = dict(self.__dict__)
|
|
|
|
def __setattr__(self, name, value):
|
|
if name != "_attributes" and name not in self._attributes:
|
|
print("attribute deleted!")
|
|
self._attributes[name] = value
|
|
super().__setattr__("_attributes", dict(self.__dict__))
|
|
|
|
@property
|
|
def treasure(self):
|
|
if self.__dict__ != self._attributes:
|
|
print("attribute deleted!")
|
|
return self._treasure
|
|
|