creditcardimpl.java

来自「利用CORBA的值类型实现的一个分布式程序」· Java 代码 · 共 28 行

JAVA
28
字号
// 具体值类型CreditCard的实现
package Bank;

public class CreditCardImpl extends CreditCard {
    // 构造方法一
    public CreditCardImpl(float init) {
        this(init, 0);
    }
    // 构造方法二
    public CreditCardImpl(float init, float limit) {
        balance = init;
        overdraft = limit;
    }
    // 往账户中存款
    public void deposit(float amount) {
        balance += amount;
    }
    // 从账户中取款
    public void withdraw(float amount) throws AccountOverdraft {
        if (balance + overdraft < amount)  throw new AccountOverdraft();
        else  balance -= amount;
    }
    // 查询账户余额
    public float getBalance() {
        return balance;
    }
}

⌨️ 快捷键说明

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