Initial commit
This commit is contained in:
16
Solutions/6_4/stock.py
Normal file
16
Solutions/6_4/stock.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# stock.py
|
||||
|
||||
from structure import Structure
|
||||
|
||||
class Stock(Structure):
|
||||
_fields = ('name', 'shares', 'price')
|
||||
|
||||
@property
|
||||
def cost(self):
|
||||
return self.shares * self.price
|
||||
|
||||
def sell(self, nshares):
|
||||
self.shares -= nshares
|
||||
|
||||
Stock.create_init()
|
||||
|
||||
Reference in New Issue
Block a user