diff --git a/Start/Ch 2/challenge.py b/Start/Ch 2/challenge.py index 556fd1f..32c0cdb 100644 --- a/Start/Ch 2/challenge.py +++ b/Start/Ch 2/challenge.py @@ -12,14 +12,32 @@ # For stocks: "Ticker: Company -- $Price" # For bonds: "description: duration'yr' : $price : yieldamt%" -class Asset(): - pass +class Asset(ABC): + def __init__(self, price): + self.price = price -class Stock(): - pass + @abstractmethod + def get_description(self): + pass -class Bond(): - pass +class Stock(Asset): + def __init__(self, ticker, price, company_name): + super().__init__(price) + self.ticker = ticker + self.company_name = company_name + + def get_description(self): + return f"{self.ticker}: {self.company_name} -- ${self.price}" + +class Bond(Asset): + def __init__(self, price, description, duration, yieldamt): + super().__init__(price) + self.description = description + self.duration = duration + self.yieldamt = yieldamt + + def get_description(self): + return f"{self.description}: {self.duration}yr : ${self.price} : {self.yieldamt}%" # ~~~~~~~~~ TEST CODE ~~~~~~~~~