withdrawal.java

来自「模拟了atm机的基本功能」· Java 代码 · 共 66 行

JAVA
66
字号
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Withdrawal.java

package atm.transaction;

import atm.ATM;
import atm.Session;
import atm.physical.CashDispenser;
import atm.physical.CustomerConsole;
import banking.*;

// Referenced classes of package atm.transaction:
//            Transaction

public class Withdrawal extends Transaction
{

    private int from;
    private Money amount;

    public Withdrawal(ATM atm, Session session, Card card, int i)
    {
        super(atm, session, card, i);
    }

    protected Message getSpecificsFromCustomer()
        throws atm.physical.CustomerConsole.Cancelled
    {
        from = atm.getCustomerConsole().readMenuChoice("Account to withdraw from", AccountInformation.ACCOUNT_NAMES);
        String as[] = {
            "$20", "$40", "$60", "$100", "$200"
        };
        Money amoney[] = {
            new Money(20), new Money(40), new Money(60), new Money(100), new Money(200)
        };
        String s = "";
        for(boolean flag = false; !flag;)
        {
            amount = amoney[atm.getCustomerConsole().readMenuChoice(s + "Amount of cash to withdraw", as)];
            flag = atm.getCashDispenser().checkCashOnHand(amount);
            if(!flag)
                s = "Insufficient cash available\n";
        }

        return new Message(0, card, pin, serialNumber, from, -1, amount);
    }

    protected Receipt completeTransaction()
    {
        atm.getCashDispenser().dispenseCash(amount);
        return new Receipt(atm, card, this, balances) {

            
            {
                detailsPortion = new String[2];
                detailsPortion[0] = "WITHDRAWAL FROM: " + AccountInformation.ACCOUNT_ABBREVIATIONS[from];
                detailsPortion[1] = "AMOUNT: " + amount.toString();
            }
        };
    }


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?