python-mastery/stock.py
2023-12-10 10:39:45 -06:00

17 lines
281 B
Python

from structure import Structure
class Stock(Structure):
def __init__(self, name, shares, price):
self._init()
@property
def cost(self):
return self.shares * self.price
def sell(self, nshares):
self.shares -= nshares
Stock.set_fields()