#include "Rectangle.h" // include class declaration

// Member function implementation section



/********************************************************************

 *                     Rectangle::setLength                         *

 * This function sets the value of the member variable length.      *

 * If the argument passed to the function is zero or greater, it is *

 * copied into length. If it is negative, 1.0 is assigned to length.*

 ********************************************************************/

void Rectangle::setLength(double len)

{

	if (len >= 0)

		length = len;

	else

	{	length = 1.0;

		cout << "Invalid length. Using a default value of 1.\n";

	}

}



/********************************************************************

 *                      Rectangle::setWidth                         *

 * This function sets the value of the member variable width.       *

 * If the argument passed to the function is zero or greater, it is *

 * copied into width. If it is negative, 1.0 is assigned to width.  *

 ********************************************************************/

void Rectangle::setWidth(double w)

{

	if (w >= 0)

		width = w;

	else

	{	width = 1.0;

		cout << "Invalid width. Using a default value of 1.\n";

	}

}



/**************************************************************

 *                     Rectangle::getLength                   *

 * This function returns the value in member variable length. *

 **************************************************************/

//double Rectangle::getLength()

//{

//	return length;

//}



/**************************************************************

 *                     Rectangle::getWidth                    *

 * This function returns the value in member variable width.  *

 **************************************************************/

double Rectangle::getWidth()

{

	return width;

}



/*******************************************************************

 *                        Rectangle::getArea                       *

 * This function calculates and returns the area of the rectangle. *

 *******************************************************************/

double Rectangle::getArea()

{

	return length * width;

}

