FileDocCategorySizeDatePackage
Dollar.javaAPI DocExample2606Thu Oct 13 14:57:46 BST 2005com.samscdrental.model.adt

Dollar

public class Dollar extends Object implements Serializable

Title: Sams CD Rental Store

Description:

Copyright: Copyright (c) 2004

Company:

author
Ken Pugh
version
1.0

Fields Summary
private static final long
serialVersionUID
private BigDecimal
theValue
static final String
ERROR_DOLLAR_BAD_FORMAT
Constructors Summary
public Dollar()

 

	 
	
	
public Dollar(double value)

		theValue = new BigDecimal( value );
	
private Dollar(String aString)
PhysicalID

param
aString String

		fromString( aString );

	
Methods Summary
public booleanequals(com.samscdrental.model.adt.Dollar aDollar)
Indicates whether some other object is "equal to" this one.

param
obj the reference object with which to compare.
return
true if this object is the same as the obj argument; false otherwise.
todo
Implement this java.lang.Object method

		return aDollar.theValue.equals( theValue );
	
public booleanequals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

param
obj the reference object with which to compare.
return
true if this object is the same as the obj argument; false otherwise.
todo
Implement this java.lang.Object method

		return equals( ( Dollar ) obj );
	
voidfromDouble(double value)

		theValue = new BigDecimal( value );

	
public voidfromString(java.lang.String aString)
fromString

param
aString String
return
boolean

		String s = aString.trim();
		s.replaceAll( ",", "" );
		if ( s.startsWith( "$" ) )
		{
			s = s.substring( 1 );
		}
		try
		{
			theValue = new BigDecimal( s );
		}
		catch ( NumberFormatException exception )
		{
			throw new DollarFormatDeviation( ERROR_DOLLAR_BAD_FORMAT + aString );
		}

		return;
	
public static com.samscdrental.model.adt.DollarparseString(java.lang.String aString)

		return new Dollar( aString );
	
public java.lang.StringtoString()
Returns a string representation of the object.

return
a string representation of the object.
todo
Implement this java.lang.Object method

		return NumberFormat.getCurrencyInstance().format( theValue );