python-mastery/Solutions/6_3/stock.py

18 lines
292 B
Python
Raw Normal View History

2023-07-17 03:21:00 +02:00
# stock.py
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()