accountimpl.java

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

JAVA
23
字号
// 值类型Account的实现
package Bank;

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

⌨️ 快捷键说明

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