📄 16d.txt
字号:
// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -