/**
 * A utility class that can be used to calculate sales
 * taxes on a collection of items
 *
 *
 * This work complies with the JMU Honor Code.
 *
 * @author  Your Name
 * @version 1.0
 */
    public class TaxCalculator
   {
      public static int NON_FOOD        = 0;
      public static int FOOD            = 1;
      public static int PREPARED_FOOD   = 2;
    
   
    /**
     * Calculate the tax on the (non-prepared) food items
     *
     * @param prices      The prices of all items
     *                    	purchases
     * @param categories  The corresponding categories of
     *                   	 all items purchases
     * @return            The tax
     */
       public static double foodTax(double[] prices,
       	int[] categories)
      {
         double tax;
       
         tax = 0.0;//zero by default
       
         for(int x =0; x<prices.length; x++)//loops 
            if (categories[x]==FOOD)//throuogh the array
               tax+= StateTaxes.foodTax(prices[x]);
        //uses the foodTax method and sums up everything 
       //it returns into the total tax value to 
      //be returned
      
         return tax;       
      }//end of method
   
   
    /**
     * Calculate the tax on the non-food items
     *
     * @param prices      The prices of all items
     *							purchases
     * @param categories  The corresponding categories of 
     *                		all items purchases
     * @return            The tax
     */
       public static double nonfoodTax(double[] prices,
       	int[] categories)
      {
         double tax;
       
         tax = 0.0;//zero by default
       
         for(int x =0; x<prices.length; x++)//loops
            if (categories[x]==NON_FOOD)//through array
               tax+= StateTaxes.salesTax(prices[x]);
       //uses the salesTax method and sums up everything 
      //returned into the total tax value to be returned
      
         return tax;       
      }//end of method
    
   
    /**
     * Calculate the tax on the prepared food items
     *
     * @param prices      The prices of all items
     *							purchases
     * @param categories  The corresponding categories of
     *                    	all items purchases
     * @return            The tax
     */
       public static double preparedfoodTax
       	(double[] prices,int[] categories)
      {
         double tax;
       
         tax = 0.0;//zero by default
       
         for(int x =0; x<prices.length; x++)
            if (categories[x]==PREPARED_FOOD)
               tax+=
                  LocalTaxes.preparedFoodTax(prices[x]);
        //uses the preparedFoodTax method and sums up 
       //everything it returns into the total tax value 
      //to be returned
      
         return tax;       
      }//end of method
   
   
    /**
     * Calculate the total value of all items purchased
     * in particular category
     *
     * @param prices      The prices of all items 
     *                    	purchases
     * @param categories  The corresponding categories of
     *                    	all items purchases
     * @param categoryToInclude  The category of interest
     * @return            The total value of items in the 
     *                    	given category
     */
       public static double total(double[] prices, 
       	int[] categories,int categoryToInclude)
      {
         double     total;
       
         total = 0.00;//zero by default
         for(int x =0; x<prices.length; x++)
         {//one of the if-blocks will add up the prices
         //of the category included, depending on which
            if (NON_FOOD==categoryToInclude &&
            	 categories[x]==categoryToInclude)
               total+=prices[x];//adds up non-food items
            
            if (FOOD==categoryToInclude &&
            	 categories[x]==categoryToInclude)
               total+= prices[x];//adds up food items
               
            if (PREPARED_FOOD==categoryToInclude &&
            	 categories[x]==categoryToInclude)
               total+= prices[x];//adds up prepared items
         }//end of for-loop
         return total;       
      }//end of method
    
    
    /**
     * Determine if the given category is valid
     *
     * @param category   The category of interest
     * @return           true if the category is valid;
     *                   	false otherwise
     */
       public static boolean isValid(int category)
      {
         boolean     result;
       
         result = false;//false by default
       
       //checks to see if the int is within range
         if(category>=0 && category<=2)//the range is
            result=true;              //0,1, and 2.
       
         return result;       
      }//end method
   }