package account;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;
import java.util.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;
import java.util.*;
public class AccountManager {
private static Scanner can=new Scanner(System.in);
private Vector<Account> map=new Vector<Account>();
private Vector<Account> maplist=new Vector<Account>();
private final String szM[]=new String[]{"存款","取款","转账","修改密码","查询"};
private Iterator<Account> it;
private String cnum;
private int go;
private int index;
private int an;
private Account me=new Account();
public static void main(String[] args) {
AccountManager a=new AccountManager();
try {
a.daoru_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
a.go=3;
a.start();
}
public void start()
{
index=0;
an=0;
System.out.println("***************************************************************");
System.out.println(" 欢迎使用中国工商银行自动柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入您的账号:");
if(can.hasNext())
{
cnum=can.next();
}
if(cnum.length()==8)
{
// TODO 自动生成的方法存根
if(isfind(cnum))
{
index=lookp(cnum)-1;
showpass();
}
else
{
System.out.println(" 没有找到相关账户信息,请重新输入");
start();
}
}
else
{
System.out.println(" 输入的账户信息不是八位数,请重新输入");
start();
}
}
public void showpass()
{
try {
daoru_2();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入您的密码:");
if(can.hasNext())
{
cnum=can.next();
}
if(cnum.length()==6)
{
if(Integer.parseInt(cnum)==me.getAccountpassword())
{
insystem();
}
else
{
if(go>0)
{
System.out.println(" 密码错误,请重新输入,还剩"+go+"次机会重新输入");
showpass();
go--;
}
else
{
System.out.println(" 密码错误输入次数过多,返回账号输入菜单");
start();
go=3;
}
}
}
else
{
System.out.println(" 输入的密码信息不是六位数,请重新输入");
showpass();
}
}
public void insystem()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 1.存款");
System.out.println(" 2.取款");
System.out.println(" 3.转账汇款");
System.out.println(" 4.修改密码");
System.out.println(" 5.查询余额");
System.out.println(" q.登录菜单");
int type=0;
if(can.hasNextInt())
{
type=can.nextInt();
}
else
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面");
start();
go=3;
return;
}
else
{
System.out.println("输入错误,请重新输入");
insystem();
return;
}
}
func(type);
}
public void func(int type)
{
if(type==1)
{
cunkuang();
}
else if(type==2)
{
qukuang();
}
else if(type==3)
{
zhuangzhang();
}
else if(type==4)
{
xiugai();
}
else if(type==5)
{
chaxun();
}
}
public void zhuangzhang()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入你要转账的账号:");
String type=null;
if(can.hasNext())
{
type=can.next();
}
if(isfind_1(type))
{
if((an=lookp(type)-1)!=-1)
{
jiner();
}
}
else
{
System.out.println(" 查无此账号");
System.out.println(" 按q输入回车回到账号输入菜单,按其他任意键回到主菜单 ");
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面 ");
start();
go=3;
return;
}
else insystem();
}
}
}
public void jiner()
{
int c=0;
System.out.println(" 请输入你要转账的金额:");
if(can.hasNextInt())
{
c=can.nextInt();
}
if(me.getAccountbalance()>=c)
{
Account ss=new Account();
me.setAccountbalance(me.getAccountbalance()-c);
me.setAmount(me.getAmount()-c);
me.setOperatetype(3);
ss=me;
map.get(an).setAccountbalance(map.get(an).getAccountbalance()+c);
map.get(an).setAmount(map.get(an).getAmount()+c);
map.get(an).setOperatetype(1);
map.setElementAt(ss, index);
//1
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户向"+map.get(an).getAccountname()+"成功转账"+c+"元。");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println("*************************************************************** ");
insystem();
}
else
{
System.out.println("金额不够,不能转");
zhuangzhang();
}
}
public void xiugai()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入你原来的密码:");
int type=0,g_old=0,g_new=0;
if(can.hasNextInt())
{
type=can.nextInt();
}
if(type==me.getAccountpassword())
{
System.out.println(" 请输入你要修改的密码:");
if(can.hasNextInt())
{
g_old=can.nextInt();
}
if(!(g_old>=100000&&g_old<=999999))
{
System.out.println(" 密码输入格式错误,请重新输入");
xiugai();
return;
}
System.out.println(" 请再次你输入你要修改的密码:");
if(can.hasNextInt())
{
g_new=can.nextInt();
}
if(g_new==g_old)
{
Account ss=new Account();
me.setAccountpassword(g_old);
me.setOperatetype(4);
ss=me;
map.setElementAt(ss, index);
//1
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 密码修改成功");
System.out.println("*************************************************************** ");
System.out.println(" 按q输入回车回到账号输入菜单,按其他任意键回到主菜单 ");
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面 ");
start();
go=3;
return;
}
else insystem();
}
}
}
}
public void chaxun()
{
me.setOperatetype(5);
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println(" 账号清单信息为:");
it=maplist.iterator();
int i=1;
Account st=new Account();
while(it.hasNext())
{
st=it.next();
if(st.getAccountID().equals(me.getAccountID()))
{
System.out.println(" "+i+"、"+st.getOperatedate()+" "+szM[st.getOperatetype()-1]+" "+st.getAmount());
i++;
}
}
if(i==1)
System.out.println("用户尚无操作");
System.out.println("*************************************************************** ");
Account ss=new Account();
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
//1
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
insystem();
}
public void qukuang()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户每日可以支取2万元。");
System.out.println(" 1.100元");
System.out.println(" 2.500元");
System.out.println(" 3.1000元");
System.out.println(" 4.1500元");
System.out.println(" 5.2000元");
System.out.println(" 6.5000元");
System.out.println(" 7.其他金额");
System.out.println(" 8.退卡");
System.out.println(" 9.返回");
int type=0;
if(can.hasNextInt())
{
type=can.nextInt();
}
cunkuangi(type);
}
public void cunkuangi(int type)
{
boolean g_test=false;
Account ss=new Account();
if(type==1)
{
if(me.getAccountbalance()>=100)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-100);
me.setAmount(me.getAmount()-100);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==2)
{
if(me.getAccountbalance()>=500)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-500);
me.setAmount(me.getAmount()-500);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==3)
{
if(me.getAccountbalance()>=1000)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-1000);
me.setAmount(me.getAmount()-1000);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==4)
{
if(me.getAccountbalance()>=1500)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-1500);
me.setAmount(me.getAmount()-1500);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==5)
{
if(me.getAccountbalance()>=2000)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-2000);
me.setAmount(me.getAmount()-2000);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==6)
{
if(me.getAccountbalance()>=5000)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-5000);
me.setAmount(me.getAmount()-5000);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==7)
{
int num=0;
if(can.hasNextInt())
{
type=can.nextInt();
}
if(me.getAccountbalance()>=num)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-num);
me.setAmount(me.getAmount()-num);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==8)
{
System.out.println(" 8.退卡成功");
start();
go=3;
return;
}
else if(type==9)
{
insystem();
return;
}
if(g_test)
{
me.setOperatetype(2);
ss.setOperatetype(2);
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户取款成功");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println("*************************************************************** ");
//1
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println(" 输入q退出到账号菜单,按其他任意键回到主菜单 ");
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面");
start();
go=3;
return;
}
else insystem();
}
}
}
public void cunkuang()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入存款金额:");
int num=0;
if(can.hasNextInt())
{
num=can.nextInt();
}
else
{
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面");
start();
go=3;
return;
}
else
{
System.out.println("输入错误,请重新输入");
cunkuang();
}
}
}
if(num>0)
{
Account ss=new Account();
me.setAccountbalance(me.getAccountbalance()+num);
me.setAmount(me.getAmount()+num);
ss=me;
map.setElementAt(ss, index);
qukuangchenggong();
}
else
{
System.out.println("输入错误,请重新输入");
cunkuang();
}
}
void qukuangchenggong()
{
me.setOperatetype(1);
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户存款成功");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println("*************************************************************** ");
System.out.println(" 输入q退出到账号菜单,按其他任意键回到主菜单 ");
//1
Account ss=new Account();
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面");
start();
go=3;
return;
}
else insystem();
}
}
public void daoru_1() throws IOException
{
File a=new File("accountinformation.txt");
FileInputStream b = new FileInputStream(a);
map.clear();
InputStreamReader c=new InputStreamReader(b,"UTF-8");
{
BufferedReader bufr =new BufferedReader(c);
String line = null;
boolean g_tr=false;
while((line = bufr.readLine())!=null){
if(!g_tr)
{
g_tr=true;
continue;
}
Account st=new Account();
String ook[]=line.split(" ");
st.set(ook[0],ook[1], Integer.parseInt(ook[2]),Integer.parseInt(ook[3]));
map.add(st);
}
bufr.close();
//System.out.println(sb.toString());
}
c.close();
b.close();
}
public void daoru_2() throws IOException
{
File a=new File("accountlist.txt");
FileInputStream b = new FileInputStream(a);
InputStreamReader c=new InputStreamReader(b,"UTF-8");
{
BufferedReader bufr =new BufferedReader(c);
String line = null;
maplist.clear();
boolean g_tr=false;
String ostr="",temp_str="";
while((line = bufr.readLine())!=null){
if(!g_tr)
{
g_tr=true;
continue;
}
Account st=new Account();
String ook[]=line.split(" ");
st.setAccountID(ook[3]);
st.set_1(ook[0],Integer.parseInt(ook[1]),Integer.parseInt(ook[2]));
if(me.getAccountID().equals(ook[3]))
{
ostr=ook[0];
me.setAmount(Integer.parseInt(ook[1]));
me.setOperatedate(ook[0]);
}
maplist.add(st);
}
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
temp_str=sdf.format(dt);
if(!ostr.equals(temp_str))
{
me.setAmount(0);
me.setOperatedate(temp_str);
}
bufr.close();
}
c.close();
b.close();
}
public void daochu_1() throws IOException
{
Account st=new Account();
File a=new File("accountinformation.txt");
FileOutputStream b = new FileOutputStream(a);
OutputStreamWriter c=new OutputStreamWriter(b,"UTF-8");
it=map.iterator();
while(it.hasNext())
{
c.append(" ");
st=it.next();
c.append(st.getAccountID()+" "+st.getAccountname()+" "+st.getAccountpassword()+" "+st.getAccountbalance());
}
c.close();
b.close();
}
public void daochu_2() throws IOException
{
File a=new File("accountlist.txt");
FileOutputStream b = new FileOutputStream(a,true);
String temp_str="";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
temp_str=sdf.format(dt);
OutputStreamWriter c=new OutputStreamWriter(b,"UTF-8");
{
c.append(" ");
c.append(temp_str+" "+me.getAmount()+" "+me.getOperatetype()+" "+me.getAccountID());
}
c.close();
b.close();
}
//-----------------------------
public int lookp(String xuehao)
{
Account st=new Account();
int i=0;
it=map.iterator();
while(it.hasNext())
{
i++;
st=it.next();
if(st.getAccountID().equals(xuehao))
break;
}
return i;
}
public boolean isfind(String xuehao)
{
Account st=new Account();
it=map.iterator();
boolean ok=false;
while(it.hasNext())
{
st=it.next();
if(st.getAccountID().equals(xuehao))
{
me=st;
ok=true;
break;
}
}
return ok;
}
public boolean isfind_1(String xuehao)
{
Account st=new Account();
it=map.iterator();
boolean ok=false;
while(it.hasNext())
{
st=it.next();
if(st.getAccountID().equals(xuehao))
{
ok=true;
break;
}
}
return ok;
}
public void func(int type)
{
if(type==1)
{
cunkuang();
}
else if(type==2)
{
qukuang();
}
else if(type==3)
{
zhuangzhang();
}
else if(type==4)
{
xiugai();
}
else if(type==5)
{
chaxun();
}
}
public void zhuangzhang()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入你要转账的账号:");
String type=null;
if(can.hasNext())
{
type=can.next();
}
if(isfind_1(type))
{
if((an=lookp(type)-1)!=-1)
{
jiner();
}
}
else
{
System.out.println(" 查无此账号");
System.out.println(" 按q输入回车回到账号输入菜单,按其他任意键回到主菜单 ");
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面 ");
start();
go=3;
return;
}
else insystem();
}
}
}
public void jiner()
{
int c=0;
System.out.println(" 请输入你要转账的金额:");
if(can.hasNextInt())
{
c=can.nextInt();
}
if(me.getAccountbalance()>=c)
{
Account ss=new Account();
me.setAccountbalance(me.getAccountbalance()-c);
me.setAmount(me.getAmount()-c);
me.setOperatetype(3);
ss=me;
map.get(an).setAccountbalance(map.get(an).getAccountbalance()+c);
map.get(an).setAmount(map.get(an).getAmount()+c);
map.get(an).setOperatetype(1);
map.setElementAt(ss, index);
//1
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户向"+map.get(an).getAccountname()+"成功转账"+c+"元。");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println("*************************************************************** ");
insystem();
}
else
{
System.out.println("金额不够,不能转");
zhuangzhang();
}
}
public void xiugai()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入你原来的密码:");
int type=0,g_old=0,g_new=0;
if(can.hasNextInt())
{
type=can.nextInt();
}
if(type==me.getAccountpassword())
{
System.out.println(" 请输入你要修改的密码:");
if(can.hasNextInt())
{
g_old=can.nextInt();
}
if(!(g_old>=100000&&g_old<=999999))
{
System.out.println(" 密码输入格式错误,请重新输入");
xiugai();
return;
}
System.out.println(" 请再次你输入你要修改的密码:");
if(can.hasNextInt())
{
g_new=can.nextInt();
}
if(g_new==g_old)
{
Account ss=new Account();
me.setAccountpassword(g_old);
me.setOperatetype(4);
ss=me;
map.setElementAt(ss, index);
//1
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 密码修改成功");
System.out.println("*************************************************************** ");
System.out.println(" 按q输入回车回到账号输入菜单,按其他任意键回到主菜单 ");
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面 ");
start();
go=3;
return;
}
else insystem();
}
}
}
}
public void chaxun()
{
me.setOperatetype(5);
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println(" 账号清单信息为:");
it=maplist.iterator();
int i=1;
Account st=new Account();
while(it.hasNext())
{
st=it.next();
if(st.getAccountID().equals(me.getAccountID()))
{
System.out.println(" "+i+"、"+st.getOperatedate()+" "+szM[st.getOperatetype()-1]+" "+st.getAmount());
i++;
}
}
if(i==1)
System.out.println("用户尚无操作");
System.out.println("*************************************************************** ");
Account ss=new Account();
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
//1
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
insystem();
}
public void qukuang()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户每日可以支取2万元。");
System.out.println(" 1.100元");
System.out.println(" 2.500元");
System.out.println(" 3.1000元");
System.out.println(" 4.1500元");
System.out.println(" 5.2000元");
System.out.println(" 6.5000元");
System.out.println(" 7.其他金额");
System.out.println(" 8.退卡");
System.out.println(" 9.返回");
int type=0;
if(can.hasNextInt())
{
type=can.nextInt();
}
cunkuangi(type);
}
public void cunkuangi(int type)
{
boolean g_test=false;
Account ss=new Account();
if(type==1)
{
if(me.getAccountbalance()>=100)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-100);
me.setAmount(me.getAmount()-100);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==2)
{
if(me.getAccountbalance()>=500)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-500);
me.setAmount(me.getAmount()-500);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==3)
{
if(me.getAccountbalance()>=1000)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-1000);
me.setAmount(me.getAmount()-1000);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==4)
{
if(me.getAccountbalance()>=1500)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-1500);
me.setAmount(me.getAmount()-1500);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==5)
{
if(me.getAccountbalance()>=2000)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-2000);
me.setAmount(me.getAmount()-2000);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==6)
{
if(me.getAccountbalance()>=5000)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-5000);
me.setAmount(me.getAmount()-5000);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==7)
{
int num=0;
if(can.hasNextInt())
{
type=can.nextInt();
}
if(me.getAccountbalance()>=num)
{
g_test=true;
me.setAccountbalance(me.getAccountbalance()-num);
me.setAmount(me.getAmount()-num);
ss=me;
map.setElementAt(ss, index);
}
}
else if(type==8)
{
System.out.println(" 8.退卡成功");
start();
go=3;
return;
}
else if(type==9)
{
insystem();
return;
}
if(g_test)
{
me.setOperatetype(2);
ss.setOperatetype(2);
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户取款成功");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println("*************************************************************** ");
//1
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println(" 输入q退出到账号菜单,按其他任意键回到主菜单 ");
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面");
start();
go=3;
return;
}
else insystem();
}
}
}
public void cunkuang()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 请输入存款金额:");
int num=0;
if(can.hasNextInt())
{
num=can.nextInt();
}
else
{
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面");
start();
go=3;
return;
}
else
{
System.out.println("输入错误,请重新输入");
cunkuang();
}
}
}
if(num>0)
{
Account ss=new Account();
me.setAccountbalance(me.getAccountbalance()+num);
me.setAmount(me.getAmount()+num);
ss=me;
map.setElementAt(ss, index);
qukuangchenggong();
}
else
{
System.out.println("输入错误,请重新输入");
cunkuang();
}
}
void qukuangchenggong()
{
me.setOperatetype(1);
System.out.println("***************************************************************");
System.out.println(" 欢迎 "+me.getAccountname()+" 使用中国工商银行自助柜员系统");
System.out.println("***************************************************************");
System.out.println(" 当前账户存款成功");
System.out.println(" 当前账户余额为:"+me.getAccountbalance());
System.out.println("*************************************************************** ");
System.out.println(" 输入q退出到账号菜单,按其他任意键回到主菜单 ");
//1
Account ss=new Account();
ss.set_1(me.getOperatedate(), me.getAmount(), me.getOperatetype());
ss.setAccountID(me.getAccountID());
maplist.add(ss);
try {
daochu_2();
daochu_1();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
if(can.hasNext())
{
cnum=can.next();
if(cnum.equals("q"))
{
System.out.println("已经退出系统,返回账号界面");
start();
go=3;
return;
}
else insystem();
}
}
public void daoru_1() throws IOException
{
File a=new File("accountinformation.txt");
FileInputStream b = new FileInputStream(a);
map.clear();
InputStreamReader c=new InputStreamReader(b,"UTF-8");
{
BufferedReader bufr =new BufferedReader(c);
String line = null;
boolean g_tr=false;
while((line = bufr.readLine())!=null){
if(!g_tr)
{
g_tr=true;
continue;
}
Account st=new Account();
String ook[]=line.split(" ");
st.set(ook[0],ook[1], Integer.parseInt(ook[2]),Integer.parseInt(ook[3]));
map.add(st);
}
bufr.close();
//System.out.println(sb.toString());
}
c.close();
b.close();
}
public void daoru_2() throws IOException
{
File a=new File("accountlist.txt");
FileInputStream b = new FileInputStream(a);
InputStreamReader c=new InputStreamReader(b,"UTF-8");
{
BufferedReader bufr =new BufferedReader(c);
String line = null;
maplist.clear();
boolean g_tr=false;
String ostr="",temp_str="";
while((line = bufr.readLine())!=null){
if(!g_tr)
{
g_tr=true;
continue;
}
Account st=new Account();
String ook[]=line.split(" ");
st.setAccountID(ook[3]);
st.set_1(ook[0],Integer.parseInt(ook[1]),Integer.parseInt(ook[2]));
if(me.getAccountID().equals(ook[3]))
{
ostr=ook[0];
me.setAmount(Integer.parseInt(ook[1]));
me.setOperatedate(ook[0]);
}
maplist.add(st);
}
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
temp_str=sdf.format(dt);
if(!ostr.equals(temp_str))
{
me.setAmount(0);
me.setOperatedate(temp_str);
}
bufr.close();
}
c.close();
b.close();
}
public void daochu_1() throws IOException
{
Account st=new Account();
File a=new File("accountinformation.txt");
FileOutputStream b = new FileOutputStream(a);
OutputStreamWriter c=new OutputStreamWriter(b,"UTF-8");
it=map.iterator();
while(it.hasNext())
{
c.append(" ");
st=it.next();
c.append(st.getAccountID()+" "+st.getAccountname()+" "+st.getAccountpassword()+" "+st.getAccountbalance());
}
c.close();
b.close();
}
public void daochu_2() throws IOException
{
File a=new File("accountlist.txt");
FileOutputStream b = new FileOutputStream(a,true);
String temp_str="";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
temp_str=sdf.format(dt);
OutputStreamWriter c=new OutputStreamWriter(b,"UTF-8");
{
c.append(" ");
c.append(temp_str+" "+me.getAmount()+" "+me.getOperatetype()+" "+me.getAccountID());
}
c.close();
b.close();
}
//-----------------------------
public int lookp(String xuehao)
{
Account st=new Account();
int i=0;
it=map.iterator();
while(it.hasNext())
{
i++;
st=it.next();
if(st.getAccountID().equals(xuehao))
break;
}
return i;
}
public boolean isfind(String xuehao)
{
Account st=new Account();
it=map.iterator();
boolean ok=false;
while(it.hasNext())
{
st=it.next();
if(st.getAccountID().equals(xuehao))
{
me=st;
ok=true;
break;
}
}
return ok;
}
public boolean isfind_1(String xuehao)
{
Account st=new Account();
it=map.iterator();
boolean ok=false;
while(it.hasNext())
{
st=it.next();
if(st.getAccountID().equals(xuehao))
{
ok=true;
break;
}
}
return ok;
}
}