class Art:
def __init__(self,artist,title,medium,year,owner):
self.artist = artist
self.title = title
self.medium = medium
self.year = year
self.owner =owner
def __repr__(self):
return "{}. {} . {}, {}. {}, {}".format(self.artist,self.title,self.year,self.medium,self.owner.name,self.owner.location)
class Marketplace:
def init(self):
self.listings = []
def add_listing(self,new_listing):
self.listings.append(new_listing)
def remove_listing(self,expire):
self.listings.remove(expire)
def show_listing(self):
for elem in self.listings:
print(elem)
class Client:
def __init__(self,name,location,is_museum):
self.name = name
if is_museum:
self.location = location
else:
self.location = "Private Collection"
def sell_artwork(self,artwork,price):
if artwork.owner == self:
new_listing = Listing(artwork,price,self)
veneer = veneer.add_listing(new_listing)
def buy_artwork(self,artwork):
if artwork.owner != self:
art_listing = None
for listing in veneer.listings:
if listing.art == artwork:
art_listing = listing
break
if art_listing != None:
art_listing.art.owner = self
veneer.remove_listing(art_listing)
veneer = Marketplace()
edytta = Client(âEdytta Halpirâ,None,False)
moma = Client(âThe Momaâ,âNew Yorkâ,True)
girl_with_mandolin = Art(âPicasso, Pabloâ,âGirl with a Mandolin (Fanny Tellier)â,âoil on canvasâ,â1910â,edytta)
class Listing:
def __init__(self,art,price,seller):
self.art = art # equals to
self.price = price
self.seller = seller # an instance of Client
def __repr__(self):
return "{}, {}".format(self.art.title,self.price)
edytta.sell_artwork(girl_with_mandolin,â$6M(USD)â)
veneer.show_listing()
moma.buy_artwork(girl_with_mandolin)
veneer.show_listing()
Iâve a doubt how come we use veneer object inside a class,
this is throwing this error
UnboundLocalError: local variable âveneerâ referenced before assignment