Class CategoryUtil

java.lang.Object
ntnu.idatt2016.v233.SmartMat.util.CategoryUtil

public class CategoryUtil extends Object
Utility class for category
Version:
1.0
Author:
Pedro Pablo Cardona
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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
    isHalal(String name, String description, boolean isVegetarian)
    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
    isVegan(String name, String description)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CategoryUtil

      public CategoryUtil()
  • Method Details

    • defineCategory

      public static String defineCategory(String name, String description)
      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

      public static boolean isVegan(String name, String description)
      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 product
      description - the description of the food product
      Returns:
      true if the food product is vegan, false otherwise
    • isVegetarian

      public 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. A product is not vegetarian if it contains any dairy/egg-related keywords.
      Parameters:
      name - the name of the food product
      description - the description of the food product
      isVegan - true if the product is already determined to be vegan, false otherwise
      Returns:
      true if the food product is vegetarian, false otherwise
    • isHalal

      public static boolean isHalal(String name, String description, boolean isVegetarian)
      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 product
      description - the description of the food product
      isVegetarian - true if the product is already determined to be vegetarian, false otherwise
      Returns:
      true if the food product is halal, false otherwise
    • getCategoryName

      public static String getCategoryName(int categoryNumber)
      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