MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / Stock

Class Stock

Solutions/7_3/stock.py:6–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4from validate import String, PositiveInteger, PositiveFloat
5
6class Stock(Structure):
7 name = String()
8 shares = PositiveInteger()
9 price = PositiveFloat()
10
11 @property
12 def cost(self):
13 return self.shares * self.price
14
15 def sell(self, nshares: PositiveInteger):
16 self.shares -= nshares

Callers

nothing calls this directly

Calls 3

StringClass · 0.90
PositiveIntegerClass · 0.90
PositiveFloatClass · 0.90

Tested by

no test coverage detected