ATM系统实现[12]——抽象转户类[00原创]
2007-07-23 20:27
701 查看
package cn.edu.ynu.sei.atm.account;
import cn.edu.ynu.sei.atm.interfaceDef.IBankAccount;
import cn.edu.ynu.sei.atm.sqlManager.SqlStatementsManager;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* 银行帐户抽象类
*
* @author 88250
*/
public abstract class BankAccount extends UnicastRemoteObject implements
IBankAccount
{
/**
* SQL语句管理器对象
*/
protected SqlStatementsManager sqlSM = SqlStatementsManager.getInstance();
/**
* 帐户帐号
*/
protected int accountID = 0;
/**
* 交易的总金额数
*/
protected float amount = 0;
/**
* 帐户结余
*/
protected float balance = 0;
/**
* 当天还可以取款金额数
*/
protected float remain = 0;
/**
* 交易时间
*/
protected String date = null;
/**
* 创建一个帐户实例
*
* @throws RemoteException
*/
public BankAccount() throws RemoteException
{
super();
balance = getBalance();
remain = getRemain();
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setRemain(float)
*/
public abstract void setRemain(float remain) throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getRemain()
*/
public abstract float getRemain() throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#deposit(float)
*/
public void deposit(float amount) throws RemoteException
{
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#withdraw(float)
*/
public void withdraw(float amount) throws RemoteException
{
// 生成取款时间
GregorianCalendar theTime = new GregorianCalendar();
date = formatTime(theTime.get(Calendar.YEAR), theTime
.get(Calendar.MONTH), theTime.get(Calendar.DAY_OF_MONTH),
theTime.get(Calendar.HOUR_OF_DAY),
theTime.get(Calendar.MINUTE), theTime.get(Calendar.SECOND));
// 设置当天还可以取款金额数
if (getLatedTime(accountID).substring(0, 10).equals(
date.substring(0, 10)))
{// 确定是在同一天
setRemain(getRemain() - getAmount());
}
else
{// 新一天的取款
setRemain(5000 - getAmount());
}
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getAmount()
*/
public float getAmount() throws RemoteException
{
return amount;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setAmount(float)
*/
public void setAmount(float amount) throws RemoteException
{
this.amount = amount;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setBalance(float)
*/
public abstract void setBalance(float balance) throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getBalance()
*/
public abstract float getBalance() throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setID(int)
*/
public void setID(int accountID) throws RemoteException
{
this.accountID = accountID;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getID()
*/
public int getID() throws RemoteException
{
return accountID;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getAccountType()
*/
public abstract String getAccountType() throws RemoteException;
/**
* 返回最近一次交易事务的时间
*
* @param accountID
* 帐户帐号
* @return 交易时间
*/
protected String getLatedTime(int accountID)
{
return sqlSM.getLatedTime(accountID);
}
/**
* 转化时间格式
*
* @param year
* 年
* @param month
* 月
* @param day
* 日
* @param hour
* 时
* @param minute
* 分
* @param second
* 秒
* @return 格式为yyyy-mm-dd hh:mm:ss的<code>String</code>
*/
public static String formatTime(int year, int month, int day, int hour,
int minute, int second)
{
String date = null;
if (month > 9)
{
date = Integer.toString(year) + "-" + Integer.toString(month) + "-"
+ Integer.toString(day) + " ";
}
else
{
date = Integer.toString(year) + "-0" + Integer.toString(month)
+ "-" + Integer.toString(day) + " ";
}
String time = Integer.toString(hour) + ":" + Integer.toString(minute)
+ ":" + Integer.toString(second);
return date + time;
}
}
import cn.edu.ynu.sei.atm.interfaceDef.IBankAccount;
import cn.edu.ynu.sei.atm.sqlManager.SqlStatementsManager;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* 银行帐户抽象类
*
* @author 88250
*/
public abstract class BankAccount extends UnicastRemoteObject implements
IBankAccount
{
/**
* SQL语句管理器对象
*/
protected SqlStatementsManager sqlSM = SqlStatementsManager.getInstance();
/**
* 帐户帐号
*/
protected int accountID = 0;
/**
* 交易的总金额数
*/
protected float amount = 0;
/**
* 帐户结余
*/
protected float balance = 0;
/**
* 当天还可以取款金额数
*/
protected float remain = 0;
/**
* 交易时间
*/
protected String date = null;
/**
* 创建一个帐户实例
*
* @throws RemoteException
*/
public BankAccount() throws RemoteException
{
super();
balance = getBalance();
remain = getRemain();
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setRemain(float)
*/
public abstract void setRemain(float remain) throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getRemain()
*/
public abstract float getRemain() throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#deposit(float)
*/
public void deposit(float amount) throws RemoteException
{
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#withdraw(float)
*/
public void withdraw(float amount) throws RemoteException
{
// 生成取款时间
GregorianCalendar theTime = new GregorianCalendar();
date = formatTime(theTime.get(Calendar.YEAR), theTime
.get(Calendar.MONTH), theTime.get(Calendar.DAY_OF_MONTH),
theTime.get(Calendar.HOUR_OF_DAY),
theTime.get(Calendar.MINUTE), theTime.get(Calendar.SECOND));
// 设置当天还可以取款金额数
if (getLatedTime(accountID).substring(0, 10).equals(
date.substring(0, 10)))
{// 确定是在同一天
setRemain(getRemain() - getAmount());
}
else
{// 新一天的取款
setRemain(5000 - getAmount());
}
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getAmount()
*/
public float getAmount() throws RemoteException
{
return amount;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setAmount(float)
*/
public void setAmount(float amount) throws RemoteException
{
this.amount = amount;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setBalance(float)
*/
public abstract void setBalance(float balance) throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getBalance()
*/
public abstract float getBalance() throws RemoteException;
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#setID(int)
*/
public void setID(int accountID) throws RemoteException
{
this.accountID = accountID;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getID()
*/
public int getID() throws RemoteException
{
return accountID;
}
/*
* (non-Javadoc)
*
* @see cn.edu.ynu.sei.atm.interfaceDef.IBankAccount#getAccountType()
*/
public abstract String getAccountType() throws RemoteException;
/**
* 返回最近一次交易事务的时间
*
* @param accountID
* 帐户帐号
* @return 交易时间
*/
protected String getLatedTime(int accountID)
{
return sqlSM.getLatedTime(accountID);
}
/**
* 转化时间格式
*
* @param year
* 年
* @param month
* 月
* @param day
* 日
* @param hour
* 时
* @param minute
* 分
* @param second
* 秒
* @return 格式为yyyy-mm-dd hh:mm:ss的<code>String</code>
*/
public static String formatTime(int year, int month, int day, int hour,
int minute, int second)
{
String date = null;
if (month > 9)
{
date = Integer.toString(year) + "-" + Integer.toString(month) + "-"
+ Integer.toString(day) + " ";
}
else
{
date = Integer.toString(year) + "-0" + Integer.toString(month)
+ "-" + Integer.toString(day) + " ";
}
String time = Integer.toString(hour) + ":" + Integer.toString(minute)
+ ":" + Integer.toString(second);
return date + time;
}
}
相关文章推荐
- ATM系统实现[1]——用户登录界面[00原创]
- ATM系统实现[9]——事务查询窗口[00原创]
- ATM系统实现[15]——身份验证类[00原创]
- ATM系统实现[19]——服务端[00原创]
- ATM系统实现[2]——密码修改窗口[00原创]
- ATM系统实现[10]——转帐窗口[00原创]
- ATM系统实现[3]——余额查询窗口[00原创]
- ATM系统实现[11]——取款窗口[00原创]
- ATM系统实现[17]——数据格式验证类[00原创]
- ATM系统实现[4]——帐户选择窗口[00原创]
- ATM系统实现[5]——注意事项窗口[00原创]
- ATM系统实现[6]——密码面板组件[00原创]
- ATM系统实现[13]——业务帐户类[00原创]
- ATM系统实现[7]——服务选择窗口[00原创]
- ATM系统实现[14]——可用帐户类[00原创]
- ATM系统实现[8]——转帐查询窗口[00原创]
- ATM系统实现[16]——交易事务类[00原创]
- ATM系统实现[18]——数据管理类[00原创]
- ATM系统开发日志[4] [00原创]
- ATM系统开发日志[5] [00原创]