/**
*  @version for Part II - question 4,5,6
*/

public class Length
{
            // remind class about atributes being private
     private int feet, inches, sign;  
	  private  final int INCHES_PER_FOOT = 12;
	  /**
	  *  explicit three value constructor
	  *  @param length in feet 
	  *  @param length in inches
	  *  @param boolean true means sign is positive, false means its negative)
	  */ 
	  public Length (int numFeet, int numInches, boolean booleanSign)
	  {
	      this.feet = numFeet;
			this.inches = numInches;
			if (booleanSign)
			    this.sign = +1;
			else
			    this.sign = -1;
	  }
	  
	  /**
	  *  explicit two value constructor which makes sign positive
     *  @param length in feet 
	  *  @param length in inches
	  */ 
	  public Length (int numFeet, int numInches)
	  {
	        this(numFeet, numInches, true); // object is calling its own constructor
	  }
	  
	  /**
	  *  default constructor sets feet and inches to 0, sign to positive
	  */
	  public Length ()
	  {
          this(0,0); // this is how object calls its own constructor
	  }
	  
	  /**
	  * this method returns nothing but changes the calling objects length
	  * by the Length passed in.
	  * 
	  * @param a Length
	  */
	  public void changeBy (Length aLength)
	  {
                  // convert parameter Length to inches
			 tempInches = aLength.toInches();
    
	  					// determine whether adding or subtracting      
			 tempInches = tempInches * aLength.sign;
			 
			 		   // change this.Length to inches and combine it
			 tempInches = this.toInches() + tempInches;
			
			         // convert inches to feet using integer division
			 this.feet = tempInches / INCHES_PER_FOOT;
			 
			        // determine number of inches left over
					  // after converting inches to feet
			 this.inches = tempInches = this.feet * INCHES_PER_FOOT;
		}
			 
	  }
	  
	  /**
	  *  method that returns a boolean value and is passed a Length
	  *  method checks to see whether this length has the same value
	  *  as the Length parameter passe in  
	  *
	  *  @return  true if lengths are the same, false if they are different
	  */
	  public boolean equals(Length eLength)
	  {
	     int tempParameterInches, tempObjectInches;
		  boolean answer;
		  
		  answer = false;   // not checked yet, can't be same
		  
		      // convert both objects to inches
		  tempParameterInches = eLength.toInches();
		  tempObjectInches = this.toInches();
		  
		        // if equal change answer to true, else leave false
		   if (tempParameterInches == tempObjectInches)
		    answer = true;
		}	
		 
	 /**
	 *  private method converting a Length in feet and inches to inches
	 *
	 *  @return  number of inches in Length (i.e.  1 ft  5 in returns 17)
	 */
	 private int toInches()
	 {
	      int convertedValue;
			
			convertedValue = INCHES_PER_FOOT * this.feet + this.inches;
			return convertedValue;
	 }
	 
	  /** 
	 * this method returns a String representation of the length
	 * that called it
	 *
	 * @return String value of Length
	 */
	 public String toString()
	 {
	   return " " + this.feet + " feet " + this.inches + " inches ";
	 }

	 
  }
		 