Class Length

java.lang.Object

  extended by Length


public class Lengthextends java.lang.Object

This class constructs and manipulates a Length object which consists of feet and inches


Field Summary

(package private)  int

numberOfFeet
           

(package private)  int

numberOfInches
           

(package private)  int

sign
           

 

Constructor Summary

Length()
          default constructor for objects of class Length It has no parameters It sets initializes instance variables feet & inches to 0 by making them parameters in its call to the 2 parameter constructor

 

Length(int numberOfFeet, int numberOfInches)
          This is the two parameter explicit value constructor it sets the attribute variables to the values passed in through the parameter list and calls the three value constructor with the sign a positive value (i.e.

 

Length(int numberOfFeet, int numberOfInches, boolean sign)
          This is the three parameter explicit value constructor It needs to set the int attribute for sign

 

 

Method Summary

 void

changeBy(Length someLength)
          This method alters the calling object's length by adding the parameter object's length to it.

 boolean

equals(Length aLength)
          This method returns true if the calling object's length equals the pararameter object's length

private  int

toInches()
          This method returns the equivalent number of inches in the object's Length

 java.lang.String

toString()
          This method returns the number of inches in the object's length as a String

 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

numberOfFeet

int numberOfFeet


numberOfInches

int numberOfInches


sign

int sign

Constructor Detail

Length

public Length()

default constructor for objects of class Length It has no parameters It sets initializes instance variables feet & inches to 0 by making them parameters in its call to the 2 parameter constructor


Length

public Length(int numberOfFeet,

              int numberOfInches)

This is the two parameter explicit value constructor it sets the attribute variables to the values passed in through the parameter list and calls the three value constructor with the sign a positive value (i.e. true)

Parameters:

numberOfFeet - is the object's initial number of feet

numberOfInches - is the object's intial number of inches


Length

public Length(int numberOfFeet,

              int numberOfInches,

              boolean sign)

This is the three parameter explicit value constructor It needs to set the int attribute for sign

Parameters:

numberOfFeet - is the initial number of feet in the new object

numberOfInches - is the initial number of inches in the new object

sign - indicates whether the length is positive or not (true if it is)

Method Detail

changeBy

public void changeBy(Length someLength)

This method alters the calling object's length by adding the parameter object's length to it. Remember that each Length object has its own attribute values which it knows about

Parameters:

someLength - is the Length whose attributes are to effect the change


equals

public boolean equals(Length aLength)

This method returns true if the calling object's length equals the pararameter object's length

Parameters:

aLength - is the object being compared to the calling object

Returns:

a boolean telling whether the lengths are equal or not


toString

public java.lang.String toString()

This method returns the number of inches in the object's length as a String

Overrides:

toString in class java.lang.Object

Returns:

a String representing the object's length


toInches

private int toInches()

This method returns the equivalent number of inches in the object's Length

Returns:

The length of the object in inches