Question
Question 3 (product_class.py): Develop a class called 'Product' that is initialized using the following values: 'id', 'price', 'inventory', and 'condition'. During the initialization, the value for 'condition' should be checked and if it is anything other than "New", "Used", or "Refurbished", the constructor should raise a 'ValueError'. The class should have two main methods; 'sell' and 'stock'. Both methods accept one argument, which is the quantity. The 'sell' method is called whenever a specific quantity of the product is sold. It must update the inventory and print the new inventory on the screen. If the sold quantity is greater than the inventory, a 'ValueError' should be raised. The 'stock' function is called whenever a specific quantity of the product is added to the inventory. This method must update the inventory and print the new inventory on the screen. For example, if you create a product called 'product a' with the initial inventory of 5, calling following methods should result in the following messages. product_a = Product(123, 45.88, 5, 'New') product_a.sell(3) # Available inventory: 2 product_a.stock(1) # Available inventory: 3 product_a.sell(3) # Available inventory: 0 product_a.sell(1) # ValueError: Ordered quantity cannot be greater than inventory
Question image 1