In this project, I have implemented a Product
class that represents a product in the online shopping cart system. The Product
class has the following properties:
id
(integer type): the unique identifier of the product.name
(string type): the name of the product.price
(float type): the price of the product.
In addition to the properties, the Product class should also have the following methods:
-
__construct: a constructor method that takes the id, name, and price as parameters and initializes the corresponding properties of the object.
-
getFormattedPrice: a method that returns the price of the product formatted as a string with two decimal places.
-
showDetails: a method that prints the details of the product (id, name, and formatted price) to the console.