Constructor
new Product(productId, name, categoryId, price, imageUrl, descriptionopt, isAvailableopt, isSpecialopt, recipeopt, preparationTimeopt, rankopt)
Creates a new Product.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
productId |
number | Unique identifier for the product. | ||
name |
string | Name of the product. | ||
categoryId |
number | Associated category ID for the product. | ||
price |
number | Base price of the product. | ||
imageUrl |
string | URL of the product image. | ||
description |
string |
<optional> |
"" | Brief description of the product. |
isAvailable |
boolean |
<optional> |
true | Availability status of the product. |
isSpecial |
boolean |
<optional> |
false | Indicates if the product is a special item. |
recipe |
Array.<Recipe> |
<optional> |
[] | List of recipes associated with the product. |
preparationTime |
number |
<optional> |
0 | Time in minutes required to prepare the product. |
rank |
number |
<optional> |
0 | Rank of the product. |
- Source:
Methods
getFinalPrice() → {number}
Calculates the final price of the product.
- Source:
Returns:
- The final price of the product.
- Type
- number
toggleAvailability()
Toggles the availability status of the product.
- Source:
updateDetails(name, categoryId, price, imageUrl, description, isAvailable, isSpecial, recipe, preparationTime, rank)
Updates the details of the product.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Updated name of the product. |
categoryId |
number | Updated category ID. |
price |
number | Updated price of the product. |
imageUrl |
string | Updated URL of the product image. |
description |
string | Updated description of the product. |
isAvailable |
boolean | Updated availability status. |
isSpecial |
boolean | Updated special status. |
recipe |
Array.<Recipe> | Updated list of recipes. |
preparationTime |
number | Updated preparation time in minutes. |
rank |
number | Updated rank of the product. |
- Source: