Exercise: Inventory Management
Refine your Kotlin skills by completing the implementation of essential functions in the Inventory class, focusing on effective management of products, producers, and sellers.
We'll cover the following
Problem statement
Your task is to complete the implementation of essential functions in the Inventory
class. The primary focus is on effectively managing products, producers, and sellers.
The Product
class
The Product
class is a fundamental entity in the inventory system, representing an item with unique identification, a name
, a price
, and a category
.
The Inventory
class
The Inventory
class serves as the backbone of the inventory management system. It encapsulates functionalities for adding and removing products, associating products with producers, managing sellers, and providing a detailed inventory display.
Instructions
In the given code, you are presented with the initial structure of the Inventory
class and a basic Product
class. Your task is to implement the missing functions in the Inventory
class. The methods should exhibit the following behavior:
addProduct
: It adds a product to the inventory and assigns a producer.removeProduct
: It removes a product from the inventory along with its producer.addSeller
: It adds a seller to the seller’s collection.removeSeller
: It removes a seller from the seller’s collection.getProductsCount
: It returns the number of products in the inventory.hasProduct
: It returnstrue
if the inventory contains the given product.hasProducts
: It returnstrue
if the inventory contains any products.getProducer
: It returns the producer of the given product, ornull
if the product is not in the inventory.produceInventoryDisplay
: It returns a string containing the inventory display in the following format:
Get hands-on with 1200+ tech skills courses.