ProductInventory
Class representing a product inventory.
Constructors
new ProductInventory()
new ProductInventory(): ProductInventory
Returns
Methods
addProduct()
addProduct(product): ProductDetails
Add a new product to the inventory.
Parameters
Parameter | Type | Description |
---|---|---|
product | ProductDetails | The product to be added. |
Returns
The added product details.
getAllProducts()
getAllProducts(): ProductDetails[]
Get all products in the inventory.
Returns
An array of all product details.
getProductById()
getProductById(productId): undefined | ProductDetails
Get product details by ID.
Parameters
Parameter | Type | Description |
---|---|---|
productId | string | The ID of the product. |
Returns
undefined
| ProductDetails
The product details with the specified ID.
getProductsByCategory()
getProductsByCategory(category): ProductDetails[]
Get products by category.
Parameters
Parameter | Type | Description |
---|---|---|
category | ProductCategory | The product category. |
Returns
An array of product details in the specified category.
removeProduct()
removeProduct(productId): undefined | ProductDetails
Remove a product from the inventory.
Parameters
Parameter | Type | Description |
---|---|---|
productId | string | The ID of the product to be removed. |
Returns
undefined
| ProductDetails
The removed product details.
updateProductDetails()
updateProductDetails(productId, updatedDetails): undefined | ProductDetails
Update product details.
Parameters
Parameter | Type | Description |
---|---|---|
productId | string | The ID of the product to be updated. |
updatedDetails | ProductDetails | The updated product details. |
Returns
undefined
| ProductDetails
The updated product details.