FileDocCategorySizeDatePackage
SubstitutionConstants.javaAPI DocExample2616Sun Dec 14 22:47:38 GMT 2003oreilly.hcj.constants

SubstitutionConstants

public class SubstitutionConstants extends Object
Demonstration of the aspects of substitution constants.
author
Robert Simmons jr. (kraythe)
version
$Revision: 1.3 $

Fields Summary
private static final Logger
LOGGER
Holds the logging instance.
public static final double
PI
A value for PI.
Constructors Summary
Methods Summary
protected java.lang.StringbuildLogMessage(java.lang.Exception ex)
Builds a log message from an exception.

param
ex The exception to use to build the message.
return
The constructed message.

		StringBuffer buf = new StringBuffer(200);
		StackTraceElement[] elements = ex.getStackTrace();
		buf.append("The exception ");
		buf.append(ex.getClass().getName());
		buf.append(" occurred at ");
		buf.append(Calendar.getInstance().getTime().toString());
		buf.append(" on line ");
		buf.append(elements[0].getLineNumber());
		return buf.toString();
	
public floatcalculateInterest(float rate, float principal)
Calculate interest for one time period on the principal.

param
rate The interest rate.
param
principal The principal.
return
The calculated interest.
throws
IllegalArgumentException If the interest is less than 0.0;

		final String LOG_MSG1 = "Rate cannot be less than ";
		final String LOG_MSG2 = ". The rate input = ";
		final double MIN_INTEREST = 0.0;

		// -- 
		if (rate < MIN_INTEREST) {
			LOGGER.error(LOG_MSG1 + MIN_INTEREST + LOG_MSG2 + rate);
			throw new IllegalArgumentException("rate");
		}
		return principal * rate;
	
public doublegetCircleArea(double radius)
Calculate the area of the circle with the given radius.

param
radius The radius of the circle.
return
The calculated area.


	                      	 
	     
		double area = (Math.pow(radius, 2) * PI);
		LOGGER.debug("The calculated area is " + area);
		return area;