| Wallet.java |
// Wallet Basic Wallet class
// Author: David 4/9/99
// Version: 1.0
public class Wallet
{
String ownerName;
int cash;
Wallet ( String theOwner )
{
ownerName = theOwner;
cash = 0;
}
public String getOwnerName( )
{
return ownerName;
}
public int getCash( )
{
return cash;
}
// receive adds specified amount to cash in hand.
public void receive( int amount )
{
cash = cash + amount;
}
// payOut reduces cash by specified amount if available,
// & returns true. Leaves cash unchanged & returns
// false if not enough cash!
public boolean payOut( int amount )
{
if ( amount <= cash )
{
cash = cash - amount;
return true;
} else
return false;
}
} // end Wallet class