Class StatisticUtil

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

public class StatisticUtil extends Object
A utility class for calculating statistics related to waste and CO2 emissions.
Version:
1.0
Author:
Pedro Cardona
  • Constructor Details

    • StatisticUtil

      public StatisticUtil()
  • Method Details

    • getAnnualAverage

      public static double getAnnualAverage(List<Waste> wastes, int number)
      Calculates the annual average amount of CO2 emissions per person based on a list of waste objects and a number of persons.
      Parameters:
      wastes - a list of waste objects
      number - the number of persons
      Returns:
      the annual average amount of CO2 emissions per person
    • getNumberOfWasteByCategoryName

      public static double[] getNumberOfWasteByCategoryName(List<Waste> wastes)
      Get the number of waste items for each category name in a list of waste items.
      Parameters:
      wastes - The list of waste items for which to calculate the number of items by category name.
      Returns:
      An array of doubles representing the number of waste items for each category name.
    • getNumberOfWasteByLastMonth

      public static double[] getNumberOfWasteByLastMonth(List<Waste> wastes)
      Calculates the sum of waste for each of the four previous months. The amount of waste is converted to kilograms if the unit is in liters, grams, milliliters, centiliters, or deciliters.
      Parameters:
      wastes - the list of wastes to calculate the sum from
      Returns:
      an array of four doubles representing the sum of waste for each of the last four months, in the same order as the months are counted backwards from the current month
    • getLostMoneyInLastMonth

      public static double getLostMoneyInLastMonth(List<Waste> wastes)
      Calculates the total amount of money lost due to expired or discarded items in the last 30 days, based on the list of wastes passed as a parameter.
      Parameters:
      wastes - the list of wastes to be analyzed
      Returns:
      the total amount of money lost due to expired or discarded items in the last 30 days