
/** put your documentation for this class here
   See Style Guild for format
*/
public class ISPCharge
{
	private final double A_CEILING = 10.0;
	private final double A_PRICE_HOUR = 2.0;
	private final double A_PRICE_MONTH = 9.95;
	private final double B_CEILING = 20.0;
	private final double B_PRICE_HOUR = 1.0;
	private final double B_PRICE_MONTH = 13.95;
	private final double C_PRICE_MONTH = 9.95;
	private final double TAX_RATE = .05;

   // variables describing this charge.
   private char packageCode;
   private double hours;
   private boolean addtl_hours;
   
   // declare your constants here.  They should use the private
   // visibility modifier. 
   
   /**************************************************** 
    * The constructor sets the package and hours attributes.
    * @param pkg The code for the package, A, B, or C
    * @param hours The number of hours this month
    */
    public ISPCharge(char pkg, double hrs)
    {
       this.packageCode = Character.toUpperCase(pkg);
       this.hours = hrs;
       this.addtl_hours = (this.packageCode == 'A' || this.packageCode == 'B');
    }
   
   /************************************************
    * calc charge will decide which package to apply
    * and will return the correct cost.
    *
    * @return The charges for this month.
    */
   public double calcCost()
   {
	   double cost;
	   
	   switch (packageCode)
	   {
		   case 'A': cost = calcA(); break;
		   case 'B': cost = calcB(); break;
		   case 'C': cost = calcC(); break;
		   default: cost = 0;
	   }
	   return cost;
   }

   
   /************************************************
    * calcA calculates the charges for package A
    *
    * The rest is left for you to fill in....
    */
    public double calcA()
    {  	
    	double cost;
    	
    	cost = A_PRICE_MONTH;
    	
    	if (hours > A_CEILING)
    	{
    		cost = cost + (hours - A_CEILING) * A_PRICE_HOUR;
    	} 
    	
    	return cost;
    
    }
    
    
    /************************************************
    * calcB calculates the charges for package B
    *
    * The rest is left for you to fill in....
    */
    public double calcB()
    {  	
    	double cost;
    	
    	cost = B_PRICE_MONTH;
    	
    	if (hours > B_CEILING)
    	{
    		cost = cost + (hours - B_CEILING) * B_PRICE_HOUR;
    	} 
    	
    	return cost;
    
    }
    
    
    
    /************************************************
    * calcC calculates the charges for package C
    *
    * The rest is left for you to fill in....
    */
    public double calcC()
    {
    	return C_PRICE_MONTH;
    }
    
    
    /** calcTax calculates the tax on the passed charge
     *
     * The rest is left for you to fill in....
     */
     public double calcTax()
     {
    	 return calcCost() * TAX_RATE;
     }
     
     
     /** saveWithB calculates whether or not this 
     * charge would be less if they were on plan B
     *  (NOTE: if they are on B or C, this method
     *  should return false.
     * The rest is left for you to fill in....
     */
     public boolean saveWithB()
     {
    	 // make a B charge
    	 ISPCharge b_option;
    	 boolean result;
    	 
    	 result = false;
    	 if (packageCode == 'A')
    	 {
    		 b_option = new ISPCharge('B', hours);
    		 result = this.calcCost() < b_option.calcCost();
    	 }
    	 return result;
     }
     
     /** saveWithC calculates whether or not this 
     * charge would be less if they were on plan C
     *  (NOTE: if they are on C, this method
     *  should return false.
     * The rest is left for you to fill in....
     */
     public boolean saveWithc()
     // put the saveWithc method here
     {
       	 // make a C charge
    	 ISPCharge c_option;
    	 boolean result;
    	 
    	 result = false;
    	 if (packageCode == 'A' || packageCode == 'B')
    	 {
    		 c_option = new ISPCharge('C', hours);
    		 result = this.calcCost() < c_option.calcCost();
    	 }
    	 return result;
     }
    
     /*************************************************
      * toString describes this charge.  It should include the 
      * package for this charge and the hours.
      *
      * the rest is left for you to fill in....
      */   
      public String toString()
      {
    	  return String.format("Package: %s\tHours: %f", this.packageCode, this.hours);
      }
      
      // helpful methods for the pa, not required.
      public boolean needAddtlHours()
      {
    	  return this.addtl_hours;
      }
      
      public double getAddtlHours()
      {
    	  double extra;
    	  extra = 0; 
    	  
    	  if (needAddtlHours())
    	  {
    		  if (this.packageCode == 'A' && this.hours > this.A_CEILING)
    		  {
    			  extra = this.hours - this.A_CEILING;
    		  }
    		  else if (this.packageCode == 'B' && this.hours > this.B_CEILING)
    		  {
    			  extra = this.hours - this.B_CEILING;
    		  }
    	  }
    	  
    	  return extra;
      }
      
      public double getAddtlCharge()
      {
    	  double extra;
    	  extra = 0; 
    	  
    	  if (needAddtlHours())
    	  {
    		  if (this.packageCode == 'A' && this.hours > this.A_CEILING)
    		  {
    			  extra = getAddtlHours() * this.A_PRICE_HOUR;
    		  }
    		  else if (this.packageCode == 'B' && this.hours > this.B_CEILING)
    		  {
    			  extra = getAddtlHours() - this.B_PRICE_HOUR;
    		  }
    	  }
    	  
    	  return extra;

      }
      
      public double getBase()
      {
    	  double base;
    	  if (packageCode == 'C')
    		  base = this.C_PRICE_MONTH;
    	  else if (packageCode == 'B')
    		  base = this.B_PRICE_MONTH;
    	  else
    		  base = this.A_PRICE_MONTH;
    	  
    	  return base;
    	  
      }
      
      public double getBaseHours()
      {
    	  double base;
    	  if (packageCode == 'A')
    		  base = this.A_CEILING;
    	  else 
    		  base = this.B_CEILING;
    	  return base;  
      }

	public char getPackage()
	{
		// TODO Auto-generated method stub
		return packageCode;
	}
}
    			  
    	