diff --git a/Start/Ch 3/challenge.py b/Start/Ch 3/challenge.py index 679db2b..3bb6e99 100644 --- a/Start/Ch 3/challenge.py +++ b/Start/Ch 3/challenge.py @@ -23,6 +23,12 @@ def __init__(self, ticker, price, company): self.company = company self.ticker = ticker + def __str__(self): + return f"{self.ticker}: {self.company_name} -- ${self.price}" + + def __lt__(self, other): + return self.price < other.price + class Bond(Asset): def __init__(self, price, description, duration, yieldamt): @@ -31,6 +37,12 @@ def __init__(self, price, description, duration, yieldamt): self.duration = duration self.yieldamt = yieldamt + def __str__(self): + return f"{self.description}: {self.duration}yr : ${self.price} : {self.yieldamt}%" + + def __lt__(self, other): + return self.yieldamt < other.yieldamt + # ~~~~~~~~~ TEST CODE ~~~~~~~~~ stocks = [