| | |
- builtins.object
-
- StockItem
class StockItem(builtins.object) |
| |
StockItem(stock_ref, price, tags)
Represents a single inventory item
Attributes
----------
stock_ref : str
reference id of the stock item
tags : set[str]
set of tags describing the stock item
Class Attributes
----------------
show_instrumentation : bool
Indicates if instrumentation should be printed
max_stock_add : int
maximum amount of stock that can be added to an item's stock level at a time
min_price : int | float
minimum price of any stock item
max_price : int | float
maximum price of any stock item |
| |
Methods defined here:
- __init__(self, stock_ref, price, tags)
- Creates a `StockItem` instance
Parameters
----------
stock_ref : str
stock reference id
price : int | float
stock price
tags : set[str]
set of tags describing the stock item
- __str__(self)
- Return str(self).
- add_stock(self, count)
- Add stock to an item
Parameters
----------
count : int
amount of stock to add to an item
Returns
-------
None
Raises
------
Exception
raised if `count` < 0 or `count` > `StockItem.max_stock_add`
See Also
--------
StockItem.max_stock_add : maximum amount of stock that can be added to a `StockItem`
- check_version(self)
- Checks the version of a `StockItem` instance and upgrades it if required
Returns
-------
None
- sell_stock(self, count)
- Sell stock of an item
Decreases the item's stock level
Parameters
----------
count : int
amount of stock to sell
Returns
-------
None
Raises
------
Exception
raised if `count` < 1 or `count` is greater than the available stock
Readonly properties defined here:
- price
- price : int | float
dress price
- stock_level
- stock_level : int
amount of stock in inventory
Data descriptors defined here:
- __dict__
- dictionary for instance variables
- __weakref__
- list of weak references to the object
Data and other attributes defined here:
- max_price = 500
- max_stock_add = 10
- min_price = 0.5
- show_instrumentation = True
| |