Hey guys so when i try top print vaneer.show_listing()
in order to print the artwirk and the price it will print to the consle <main.Listing object at 0x7f0d8c8b6fd0> as if i didnt have the repr method, and im pretty stuck
so this is what i did:
class Art:
def __init__(self, artist, title, year, medium, owner):
self.artist = artist
self.title = title
self.medium = medium
self.year = year
self.owner = owner
def __repr__(self):
return str(self.artist) + "." +"\"" + str(self.title)+"\"" + "." + str(self.year) +", " +str(self.medium) + ". "+str(self.owner.name)+" ," +str(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,expired_listing):
self.listings.remove(expired_listing)
def show_listing(self):
for listing in self.listings:
print(listing)
class Client:
def __init__(self, name, location, is_museum):
self.name = name
self.is_museum = is_museum
if self.is_museum:
self.location = location
else:
self.location = "Private collector"
def sell_artwork(self, artwork, price):
if artwork.owner == self:
new_listing = Listing(artwork, price, self)
vaneer.add_listing(new_listing)
class Listing:
def __init__(self, art, price, seller):
self.art = art
self.price = price
self.seller = seller
class Listing:
def __init__(self, art, price, seller):
self.art = art
self.price = price
self.seller = seller
def _repr__(self):
return '{n}, {p}'.format(n=self.art.title, p=self.price)
########################################
vaneer = Marketplace()
the_moma = Client("The moma","New York", True)
edytta = Client("Edytta Halpirt", None,False)
girl_with_mandolin = Art("Picasso, Pablo", "Girl with a Mandolin (Fanny Tellier)", 1910, "oil on canvas",edytta)
print(girl_with_mandolin)
edytta.sell_artwork(girl_with_mandolin, '6M (USD)')
vaneer.show_listing()