FileDocCategorySizeDatePackage
PurseImpl.javaAPI DocJava Card1550Wed Mar 22 21:07:24 GMT 2006com.sun.javacard.samples.RMIDemo

PurseImpl

public class PurseImpl extends javacard.framework.service.CardRemoteObject implements Purse

Fields Summary
private short
balance
private byte[]
number
Constructors Summary
public PurseImpl()

    
    
      
        super();                     // export it
        number = new byte[5];
    
Methods Summary
public voidcredit(short m)

        
        if(m<=0) UserException.throwIt(BAD_ARGUMENT);
        
        if((short)(balance+m) > MAX_AMOUNT) UserException.throwIt(OVERFLOW);
        
        balance +=m;

    
public voiddebit(short m)

        
        if(m<=0) UserException.throwIt(BAD_ARGUMENT);
        
        if((short)(balance-m) < 0) UserException.throwIt(UNDERFLOW);
        
        balance -=m;
    
public byte[]getAccountNumber()

        return number;
    
public shortgetBalance()

        return balance;
    
public voidsetAccountNumber(byte[] number)

        if(number.length != 5) UserException.throwIt(BAD_ARGUMENT);
        Util.arrayCopy(number, (short)0, this.number, (short)0, (short)5);