Class CategoryUtil
java.lang.Object
ntnu.idatt2016.v233.SmartMat.util.CategoryUtil
Utility class for category
- Version:
- 1.0
- Author:
- Pedro Pablo Cardona
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
defineCategory
(String name, String description) Static method that define the category of the product.static String
getCategoryName
(int categoryNumber) Returns the category name corresponding to the given category number.static boolean
Determines whether a food product is halal, based on its name and description, and whether it is already determined to be vegetarian or vegan.static boolean
Determines whether a food product is vegan, based on its name and description.static boolean
isVegetarian
(String name, String description, boolean isVegan) Determines whether a food product is vegetarian, based on its name and description, and whether it is already determined to be vegan or not.
-
Constructor Details
-
CategoryUtil
public CategoryUtil()
-
-
Method Details
-
defineCategory
Static method that define the category of the product.- Parameters:
name
- name of the product.description
- description of the product- Returns:
- String A possible category.
-
isVegan
Determines whether a food product is vegan, based on its name and description. A product is not vegan if it contains any meat or dairy/egg-related keywords.- Parameters:
name
- the name of the food productdescription
- the description of the food product- Returns:
- true if the food product is vegan, false otherwise
-
isVegetarian
Determines whether a food product is vegetarian, based on its name and description, and whether it is already determined to be vegan or not. A product is not vegetarian if it contains any dairy/egg-related keywords.- Parameters:
name
- the name of the food productdescription
- the description of the food productisVegan
- true if the product is already determined to be vegan, false otherwise- Returns:
- true if the food product is vegetarian, false otherwise
-
isHalal
Determines whether a food product is halal, based on its name and description, and whether it is already determined to be vegetarian or vegan. A product is not halal if it contains any haram-related keywords.- Parameters:
name
- the name of the food productdescription
- the description of the food productisVegetarian
- true if the product is already determined to be vegetarian, false otherwise- Returns:
- true if the food product is halal, false otherwise
-
getCategoryName
Returns the category name corresponding to the given category number.- Parameters:
categoryNumber
- the category number- Returns:
- the category name
- Throws:
IllegalArgumentException
- if the given category number is invalid
-