package data; import output.XMLizable; /** * class to represent money in the game * * @author Rukmal Fernando * @author Hardik Kotecha * @author Radhika Srinivasan */ public class Money implements XMLizable { Float amount; // member variable storing Money amount /** * default constructor * * @exception RuntimeException */ public Money() { throw new RuntimeException( "No contructor for default Money" ); } /** * constructor * * @param pAmount : Float value for amount of money */ public Money( Float pAmount ) { setAmount( pAmount ); } /** * constructor * * @param pValue : value of Money */ public Money( double pValue) { setAmount( new Float( pValue ) ); } /*======================================================================== | getters and setters +-----------------------------------------------------------------------*/ /** * set the amount field * * @param pFloat : value amount is set to */ public void setAmount( Float pFloat ) { amount = pFloat; } /** * get the amount value of this Money * * @return Float : amount of Money */ public Float getAmount() { return amount; } /*----------------------------------------------------------------------- | end getters and setters +======================================================================*/ /** * generate the xml representation of money * * @return String */ public String generateXML() { return new String(amount.toString()); } /** * print the XML representation of this class to the console */ public void print() { System.out.println( generateXML() ); } }