16d.txt

来自「一本关于JBuilder 应用开发的书籍,希望大家喜欢,其实我没看过的,」· 文本 代码 · 共 68 行

TXT
68
字号
// CheckingAccount.java
import javax.ejb.*;
import java.rmi.RemoteException;
public class CheckingAccount implements EntityBean 
{
  private EntityContext _context;
  public String name;
  public float balance;
  public float getBalance() 
{
    return balance;
  }
  
  public void debit(float amount) 
{
if(amount > balance) 
{
      // 当余额不足的时候,记录事务。
      _context.setRollbackOnly();
    }
else 
{
      balance = balance - amount;
    }
  }
  public void credit(float amount) 
{
    balance = balance + amount;
  }
  public AccountPK ejbCreate(String name, float balance) 
{
    this.name = name;
    this.balance = balance;
    return null;
  }
  public void ejbPostCreate(String name, float balance) 
{
  }
  public void ejbRemove() 
{
  }
  public void setEntityContext(EntityContext context) 
{
    _context = context;
  }
  public void unsetEntityContext() 
{
    _context = null;
  }
  public void ejbActivate() 
{
  }
  public void ejbPassivate() 
{
  }
  public void ejbLoad() 
{
  }
  public void ejbStore() 
{
  }
  public String toString() 
{
    return "CheckingAccount[name=" + name + ",balance=" + balance +"]";
  }
}

⌨️ 快捷键说明

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