Java面向对象程序设计大作业-ATM柜员机模拟程序

ATM柜员机模拟程序

要求使用图形用户界面:

1、通过主界面,可以进入管理员界面、用户界面、系统设置界面、退出;

2、启动软件,可以进入用户模式,也可以进入系统管理模式;

3、进入系统管理模式,需要输入管理员账号和密码,可以查看这台ATM机近期资金出入明细,可以查看这台ATM机上面操作的所有账户的历史记录和明细;

4、进入用户账号和密码的登录界面,当输入给定的卡号和密码(初始卡号16位和密码6位)时,对比系统存储的账号和密码正确,能登录ATM柜员机系统,当日出错次数操作3次,当日锁定账户不能继续操作,累计三日被锁定,需要管理员账号才能够完成解锁操作。

用户可以按照以下规则进行操作:

1、查询余额:初始余额为100000元;

2、ATM取款:每次取款金额为100的倍数,总额不超过5000元,支取金额不允许透支;

3、ATM存款:不能出现负存款,要求存钱为100的整数倍;

4、ATM转账:通过登录的用户向指定的银行账号(在系统中已经保存)转账,若银行卡不存在,则提
示银行卡号输入错误,转账成功则提示“转账成功”,并且工具日期能够实现当日转账金额的限制;

5、历史交易记录查询,要求能够保存20条以上的交易记录;

6、修改密码:新密码长度不小于6位,不允许出现6位完全相同的情况,只有旧密码正确,新密码符合要求,且两次输入相同的情况下才可以成功修改密码;

7、退卡:点击退卡,返回登录界面。

MainInterface.java

//文件名:MainInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public abstract class MainInterface implements ActionListener {
	static JFrame mainJFrame=new JFrame();
	static JLabel lbl=new JLabel("ATM柜员机模拟程序——主界面",JLabel.CENTER);
	static JButton bt_userMode=new JButton("用户模式");
	static JButton bt_systemManagementMode=new JButton("系统管理模式");
	static JButton bt_signOut=new JButton("退出");
	public static void main(String[] args) {
		mainJFrame.setTitle("ATM柜员机模拟程序——主界面");
		/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
		mainJFrame.setBounds(0, 0, 800, 600);
		mainJFrame.setLocationRelativeTo(null);
		mainJFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		Container container=mainJFrame.getContentPane();
		container.setLayout(null);
		container.add(lbl);
		lbl.setBounds(0, 75, 800, 50);
		lbl.setFont(new Font("楷体",Font.BOLD,40));
		container.add(bt_userMode);
		bt_userMode.setBounds(300, 200, 200, 50);
		bt_userMode.setFont(new Font("黑体",Font.BOLD,20));
		bt_userMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_userMode) {
					new UserLoginInterface();
					UserLoginInterface.main(args);
				}
			}
		});
		container.add(bt_systemManagementMode);
		bt_systemManagementMode.setBounds(300, 300, 200, 50);
		bt_systemManagementMode.setFont(new Font("黑体",Font.BOLD,20));
		bt_systemManagementMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_systemManagementMode) {
					new SystemSettingInterface();
					SystemSettingInterface.main(args);
				}
			}
		});
		container.add(bt_signOut);
		bt_signOut.setBounds(300, 400, 200, 50);
		bt_signOut.setFont(new Font("黑体",Font.BOLD,20));
		bt_signOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_signOut) {
					mainJFrame.dispose();
					System.exit(0);
				}
			}
		});
		mainJFrame.setVisible(true);
	}
}

UserLoginInterface.java

//文件名:UserLoginInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
public class UserLoginInterface {
	static FileReader fr;//FileReader类
	static FileWriter fw;//FileWriter类
	static SimpleDateFormat time;
	static Date date;
    static Calendar calendar;
	static JFrame mainJFrame_1=new JFrame();
	static JLabel lbl=new JLabel("ATM柜员机模拟程序——用户登录界面",JLabel.CENTER);
	static JDialog diag_message=new JDialog();
	static JLabel lb_message=new JLabel();
	static JLabel lb_name=new JLabel("账号");
	static JLabel lb_pass=new JLabel("密码");
	static JTextField tf_name=new JTextField();
	static JPasswordField pf_pass=new JPasswordField();
	static JButton bt_login=new JButton("登录");
	static JButton bt_reset=new JButton("重置");
	static JButton bt_return=new JButton("返回");
	public static void main(String[] args) {
		mainJFrame_1.setTitle("ATM柜员机模拟程序——用户登录界面");
		/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
		mainJFrame_1.setBounds(0, 0, 800, 600);
		mainJFrame_1.setLocationRelativeTo(null);
		mainJFrame_1.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		Container container=mainJFrame_1.getContentPane();
		container.setLayout(null);
		container.add(lbl);
		lbl.setBounds(0, 75, 800, 50);
		lbl.setFont(new Font("楷体",Font.BOLD,40));
		diag_message.setTitle("消息");
		diag_message.setSize(800, 600);
		diag_message.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
		diag_message.add(lb_message);
		diag_message.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		container.add(lb_name);
		lb_name.setBounds(250, 200, 50, 50);
		lb_name.setFont(new Font("黑体",Font.BOLD,20));
		container.add(lb_pass);
		lb_pass.setBounds(250, 300, 50, 50);
		lb_pass.setFont(new Font("黑体",Font.BOLD,20));
		container.add(tf_name);
		tf_name.setBounds(350, 200, 200, 50);
		tf_name.setFont(new Font("黑体",Font.BOLD,20));
		container.add(pf_pass);
		pf_pass.setBounds(350, 300, 200, 50);
		pf_pass.setFont(new Font("黑体",Font.BOLD,20));
		pf_pass.setEchoChar('*');
		container.add(bt_login);
		bt_login.setBounds(250, 400, 100, 50);
		bt_login.setFont(new Font("黑体",Font.BOLD,20));
		bt_login.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_login) {
					try {
						UserTest.main(args);
					} catch (Exception e1) {
						e1.printStackTrace();
					}
					time=new SimpleDateFormat("yyyy年MM月dd日");
					date=new Date();
                    calendar=GregorianCalendar.getInstance();
					try {
						calendar.setTime(time.parse(time.format(date)));
					} catch (ParseException e1) {
						e1.printStackTrace();
					}
					int today=calendar.get(Calendar.DATE);
					calendar.set(Calendar.DATE, today-1);
					String yesterday=time.format(calendar.getTime());
					calendar.set(Calendar.DATE, today-2);
					String theDayBeforeYesterday=time.format(calendar.getTime());
					File test_2=new File(tf_name.getText()+" "+theDayBeforeYesterday+".txt");
					File test_1=new File(tf_name.getText()+" "+yesterday+".txt");
					File test=new File(tf_name.getText()+" "+time.format(date)+".txt");
					String name=tf_name.getText();
					int r=0;
					if(test.exists()) {
						try {
							fr=new FileReader(tf_name.getText()+" "+time.format(date)+".txt");
						} catch (FileNotFoundException e1) {
							e1.printStackTrace();
						}
						BufferedReader br_1=new BufferedReader(fr);
						String temp_1="";
						String[] tempString_1=new String[2];
						String A_1=null;
						try {
							while((temp_1=br_1.readLine())!=null) {
								tempString_1=temp_1.split("\\s+");
								A_1=tempString_1[0];
							}
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						int times_1=Integer.parseInt(A_1);
						try {
							br_1.close();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fr.close();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						if(times_1>=3) {
							r=1;
							if(test_1.exists()) {
								try {
									fr=new FileReader(tf_name.getText()+" "+yesterday+".txt");
								} catch (FileNotFoundException e1) {
									e1.printStackTrace();
								}
								BufferedReader br_2=new BufferedReader(fr);
								String temp_2="";
								String[] tempString_2=new String[2];
								String A_2=null;
								try {
									while((temp_2=br_2.readLine())!=null) {
										tempString_2=temp_2.split("\\s+");
										A_2=tempString_2[0];
									}
								} catch (IOException e1) {
									e1.printStackTrace();
								}
								int times_2=Integer.parseInt(A_2);
								try {
									br_2.close();
								} catch (IOException e1) {
									e1.printStackTrace();
								}
								try {
									fr.close();
								} catch (IOException e1) {
									e1.printStackTrace();
								}
								if(times_2>=3) {
									r=2;
									if(test_2.exists()) {
										try {
											fr=new FileReader(tf_name.getText()+" "+theDayBeforeYesterday+".txt");
										} catch (FileNotFoundException e1) {
											e1.printStackTrace();
										}
										BufferedReader br_3=new BufferedReader(fr);
										String temp_3="";
										String[] tempString_3=new String[2];
										String A_3=null;
										try {
											while((temp_3=br_3.readLine())!=null) {
												tempString_3=temp_3.split("\\s+");
												A_3=tempString_3[0];
											}
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										int times_3=Integer.parseInt(A_3);
										try {
											br_3.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fr.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										if(times_3>=3) {
											r=3;
											if(r==3) {
												tf_name.setText("");
												pf_pass.setText("");
												diag_message.setLocationRelativeTo(null);
												diag_message.setVisible(true);
												lb_message.setText("请注意:当前账号连续三日出错超过3次,已被锁定,请联系管理员解锁!");
												lb_message.setFont(new Font("楷体",Font.BOLD,20));
												File unlock=new File("unlock.txt");
												if(!unlock.exists()) {
													try {
														unlock.createNewFile();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw=new FileWriter("unlock.txt");
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.write("被锁定 用户账号\t时 间\r\n");
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.flush();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
												}
												try {
													fr=new FileReader("unlock.txt");
												} catch (FileNotFoundException e1) {
													e1.printStackTrace();
												}
												BufferedReader br=new BufferedReader(fr);
												String temp="";
												String[] tempString=new String[3];
												String A=null;
												String[] B=new String[5];
												for(int i=0;i<B.length;i++) {
													try {
														while((temp=br.readLine())!=null) {
															tempString=temp.split("\\s+");
															A=tempString[0];
															B[i]=A;
														}
													} catch (IOException e1) {
														e1.printStackTrace();
													}
												}
												if(!name.equals(B[0])&&!name.equals(B[1])&&!name.equals(B[2])&&!name.equals(B[3])&&!name.equals(B[4])) {
													try {
														fw=new FileWriter("unlock.txt",true);
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.write(name+"\t"+time.format(date)+"\t"+yesterday+"\t"+theDayBeforeYesterday+"\r\n");
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.flush();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
												}
											}
										}
										else {//
											int f=0;
											for(int i=0;i<UserTest.userArrayList.size();i++) {
												if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
													f=1;
													UserTest.currentUserAccount=UserTest.userArrayList.get(i);
													UserTest.currentUserFile=new File(UserTest.currentUserAccount.userAccount+".txt");//当前用户操作文件
													File limit_transfer=new File(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
													File historyOfAll=new File("historyOfAll.txt");
													File recentFund=new File("recentFund.txt");
													File administratorFile=new File("administratorFile.txt");
													if(!UserTest.currentUserFile.exists()) {
														try {
															UserTest.currentUserFile.createNewFile();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write("时 间\t\t\t\t操作\t\t\t余额\t\t备注\r\n");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
													}
													if(!limit_transfer.exists()) {
														try {
															limit_transfer.createNewFile();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw=new FileWriter(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write("0");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
													}
													if(!historyOfAll.exists()) {
														try {
															historyOfAll.createNewFile();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw=new FileWriter("historyOfAll.txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write("用户账号\t\t\t时 间\t\t\t\t操作\t\t\t备 注\r\n");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
													}
													if(!recentFund.exists()) {
														try {
															recentFund.createNewFile();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw=new FileWriter("recentFund.txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write("时 间\t\t\t\t操作\t\t\t备 注\r\n");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
													}
													if(!administratorFile.exists()) {
														try {
															administratorFile.createNewFile();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw=new FileWriter("administratorFile.txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write("000000 000000 400000.00\r\n");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
													}
													tf_name.setText("");
													pf_pass.setText("");
													new UserInterface();
													UserInterface.main(args);
												}
												if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&!(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
													f=2;
													File limit_1=new File(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
													if(!limit_1.exists()) {
														try {
															limit_1.createNewFile();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write("1");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}								
													}
													else {
														try {
															fr=new FileReader(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
														} catch (FileNotFoundException e1) {
															e1.printStackTrace();
														}
														BufferedReader br=new BufferedReader(fr);
														String temp="";
														String[] tempString=new String[2];
														String A=null;
														try {
															while((temp=br.readLine())!=null) {
																tempString=temp.split("\\s+");
																A=tempString[0];
															}
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														int times=Integer.parseInt(A);
														try {
															br.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fr.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														times++;
														try {
															fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write(times+"");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
													}
												}
											}
											if(f!=1) {
												tf_name.setText("");
												pf_pass.setText("");
												diag_message.setLocationRelativeTo(null);
												diag_message.setVisible(true);
												lb_message.setText("请注意:您输入的账号或密码有误,请检查后再试!");
												lb_message.setFont(new Font("楷体",Font.BOLD,20));
											}
										}
									}
									if(r==2) {
										tf_name.setText("");
										pf_pass.setText("");
										diag_message.setLocationRelativeTo(null);
										diag_message.setVisible(true);
										lb_message.setText("请注意:当前账号连续两日出错超过3次,暂被锁定,请明日再试!");
										lb_message.setFont(new Font("楷体",Font.BOLD,20));
									}
								}
								else {//
									int f=0;
									for(int i=0;i<UserTest.userArrayList.size();i++) {
										if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
											f=1;
											UserTest.currentUserAccount=UserTest.userArrayList.get(i);
											UserTest.currentUserFile=new File(UserTest.currentUserAccount.userAccount+".txt");//当前用户操作文件
											File limit_transfer=new File(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
											File historyOfAll=new File("historyOfAll.txt");
											File recentFund=new File("recentFund.txt");
											File administratorFile=new File("administratorFile.txt");
											if(!UserTest.currentUserFile.exists()) {
												try {
													UserTest.currentUserFile.createNewFile();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.write("时 间\t\t\t\t操作\t\t\t余额\t\t备注\r\n");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.flush();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
											}
											if(!limit_transfer.exists()) {
												try {
													limit_transfer.createNewFile();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw=new FileWriter(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.write("0");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.flush();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
											}
											if(!historyOfAll.exists()) {
												try {
													historyOfAll.createNewFile();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw=new FileWriter("historyOfAll.txt");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.write("用户账号\t\t\t时 间\t\t\t\t操作\t\t\t备 注\r\n");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.flush();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
											}
											if(!recentFund.exists()) {
												try {
													recentFund.createNewFile();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw=new FileWriter("recentFund.txt");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.write("时 间\t\t\t\t操作\t\t\t备 注\r\n");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.flush();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
											}
											if(!administratorFile.exists()) {
												try {
													administratorFile.createNewFile();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw=new FileWriter("administratorFile.txt");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.write("000000 000000 400000.00\r\n");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.flush();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
											}
											tf_name.setText("");
											pf_pass.setText("");
											new UserInterface();
											UserInterface.main(args);
										}
										if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&!(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
											f=2;
											File limit_1=new File(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
											if(!limit_1.exists()) {
												try {
													limit_1.createNewFile();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.write("1");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.flush();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}								
											}
											else {
												try {
													fr=new FileReader(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
												} catch (FileNotFoundException e1) {
													e1.printStackTrace();
												}
												BufferedReader br=new BufferedReader(fr);
												String temp="";
												String[] tempString=new String[2];
												String A=null;
												try {
													while((temp=br.readLine())!=null) {
														tempString=temp.split("\\s+");
														A=tempString[0];
													}
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												int times=Integer.parseInt(A);
												try {
													br.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fr.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												times++;
												try {
													fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.write(times+"");
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.flush();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fw.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
											}
										}
									}
									if(f!=1) {
										tf_name.setText("");
										pf_pass.setText("");
										diag_message.setLocationRelativeTo(null);
										diag_message.setVisible(true);
										lb_message.setText("请注意:您输入的账号或密码有误,请检查后再试!");
										lb_message.setFont(new Font("楷体",Font.BOLD,20));
									}
								}
							}
							if(r==1) {
								tf_name.setText("");
								pf_pass.setText("");
								diag_message.setLocationRelativeTo(null);
								diag_message.setVisible(true);
								lb_message.setText("请注意:当前账号当日出错超过3次,暂被锁定,请明日再试!");
								lb_message.setFont(new Font("楷体",Font.BOLD,20));
							}
						}
						else {//
							int f=0;
							for(int i=0;i<UserTest.userArrayList.size();i++) {
								if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
									f=1;
									UserTest.currentUserAccount=UserTest.userArrayList.get(i);
									UserTest.currentUserFile=new File(UserTest.currentUserAccount.userAccount+".txt");//当前用户操作文件
									File limit_transfer=new File(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
									File historyOfAll=new File("historyOfAll.txt");
									File recentFund=new File("recentFund.txt");
									File administratorFile=new File("administratorFile.txt");
									if(!UserTest.currentUserFile.exists()) {
										try {
											UserTest.currentUserFile.createNewFile();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.write("时 间\t\t\t\t操作\t\t\t余额\t\t备注\r\n");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.flush();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
									}
									if(!limit_transfer.exists()) {
										try {
											limit_transfer.createNewFile();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw=new FileWriter(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.write("0");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.flush();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
									}
									if(!historyOfAll.exists()) {
										try {
											historyOfAll.createNewFile();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw=new FileWriter("historyOfAll.txt");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.write("用户账号\t\t\t时 间\t\t\t\t操作\t\t\t备 注\r\n");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.flush();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
									}
									if(!recentFund.exists()) {
										try {
											recentFund.createNewFile();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw=new FileWriter("recentFund.txt");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.write("时 间\t\t\t\t操作\t\t\t备 注\r\n");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.flush();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
									}
									if(!administratorFile.exists()) {
										try {
											administratorFile.createNewFile();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw=new FileWriter("administratorFile.txt");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.write("000000 000000 400000.00\r\n");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.flush();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
									}
									tf_name.setText("");
									pf_pass.setText("");
									new UserInterface();
									UserInterface.main(args);
								}
								if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&!(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
									f=2;
									File limit_1=new File(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
									if(!limit_1.exists()) {
										try {
											limit_1.createNewFile();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.write("1");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.flush();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}								
									}
									else {
										try {
											fr=new FileReader(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
										} catch (FileNotFoundException e1) {
											e1.printStackTrace();
										}
										BufferedReader br=new BufferedReader(fr);
										String temp="";
										String[] tempString=new String[2];
										String A=null;
										try {
											while((temp=br.readLine())!=null) {
												tempString=temp.split("\\s+");
												A=tempString[0];
											}
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										int times=Integer.parseInt(A);
										try {
											br.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fr.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										times++;
										try {
											fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.write(times+"");
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.flush();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
										try {
											fw.close();
										} catch (IOException e1) {
											e1.printStackTrace();
										}
									}
								}
							}
							if(f!=1) {
								tf_name.setText("");
								pf_pass.setText("");
								diag_message.setLocationRelativeTo(null);
								diag_message.setVisible(true);
								lb_message.setText("请注意:您输入的账号或密码有误,请检查后再试!");
								lb_message.setFont(new Font("楷体",Font.BOLD,20));
							}
						}
					}
					else {//
						int f=0;
						for(int i=0;i<UserTest.userArrayList.size();i++) {
							if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
								f=1;
								UserTest.currentUserAccount=UserTest.userArrayList.get(i);
								UserTest.currentUserFile=new File(UserTest.currentUserAccount.userAccount+".txt");//当前用户操作文件
								File limit_transfer=new File(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
								File historyOfAll=new File("historyOfAll.txt");
								File recentFund=new File("recentFund.txt");
								File administratorFile=new File("administratorFile.txt");
								if(!UserTest.currentUserFile.exists()) {
									try {
										UserTest.currentUserFile.createNewFile();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write("时 间\t\t\t\t操作\t\t\t余额\t\t备注\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
								}
								if(!limit_transfer.exists()) {
									try {
										limit_transfer.createNewFile();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write("0");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
								}
								if(!historyOfAll.exists()) {
									try {
										historyOfAll.createNewFile();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("historyOfAll.txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write("用户账号\t\t\t时 间\t\t\t\t操作\t\t\t备 注\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
								}
								if(!recentFund.exists()) {
									try {
										recentFund.createNewFile();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("recentFund.txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write("时 间\t\t\t\t操作\t\t\t备 注\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
								}
								if(!administratorFile.exists()) {
									try {
										administratorFile.createNewFile();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("administratorFile.txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write("000000 000000 400000.00\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
								}
								tf_name.setText("");
								pf_pass.setText("");
								new UserInterface();
								UserInterface.main(args);
							}
							if((tf_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)&&!(String.valueOf(pf_pass.getPassword())).equals(UserTest.userArrayList.get(i).password)) {
								f=2;
								File limit_1=new File(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
								if(!limit_1.exists()) {
									try {
										limit_1.createNewFile();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write("1");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}								
								}
								else {
									try {
										fr=new FileReader(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
									} catch (FileNotFoundException e1) {
										e1.printStackTrace();
									}
									BufferedReader br=new BufferedReader(fr);
									String temp="";
									String[] tempString=new String[2];
									String A=null;
									try {
										while((temp=br.readLine())!=null) {
											tempString=temp.split("\\s+");
											A=tempString[0];
										}
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									int times=Integer.parseInt(A);
									try {
										br.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fr.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									times++;
									try {
										fw=new FileWriter(UserTest.userArrayList.get(i).userAccount+" "+time.format(date)+".txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write(times+"");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
								}
							}
						}
						if(f!=1) {
							tf_name.setText("");
							pf_pass.setText("");
							diag_message.setLocationRelativeTo(null);
							diag_message.setVisible(true);
							lb_message.setText("请注意:您输入的账号或密码有误,请检查后再试!");
							lb_message.setFont(new Font("楷体",Font.BOLD,20));
						}
					}
				}
			}
		});
		container.add(bt_reset);
		bt_reset.setBounds(450, 400, 100, 50);
		bt_reset.setFont(new Font("黑体",Font.BOLD,20));
		bt_reset.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_reset) {
					tf_name.setText("");
					pf_pass.setText("");
				}
			}
		});
		container.add(bt_return);
		bt_return.setBounds(350, 500, 100, 50);
		bt_return.setFont(new Font("黑体",Font.BOLD,20));
		bt_return.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_return) {
					mainJFrame_1.dispose();
					MainInterface.main(args);
				}
			}
		});
		mainJFrame_1.setVisible(true);
	}
}

SystemSettingInterface.java

//文件名:SystemSettingInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class SystemSettingInterface {
	static FileReader fr;//FileReader类
	static FileWriter fw;//FileWriter类
	static JFrame mainJFrame_2=new JFrame();
	static JLabel lbl=new JLabel("ATM柜员机模拟程序——系统设置界面",JLabel.CENTER);
	static JDialog diag_message=new JDialog();
	static JLabel lb_message=new JLabel();
	static JLabel lb_name=new JLabel("帐号");
	static JLabel lb_pass=new JLabel("密码");
	static JTextField tf_name=new JTextField();
	static JPasswordField pf_pass=new JPasswordField();
	static JButton bt_login=new JButton("登录");
	static JButton bt_reset=new JButton("重置");
	static JButton bt_return=new JButton("返回");
	public static void main(String[] args) {
		mainJFrame_2.setTitle("ATM柜员机模拟程序——系统设置界面");
		/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
		mainJFrame_2.setBounds(0, 0, 800, 600);
		mainJFrame_2.setLocationRelativeTo(null);
		mainJFrame_2.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		Container container=mainJFrame_2.getContentPane();
		container.setLayout(null);
		container.add(lbl);
		lbl.setBounds(0, 75, 800, 50);
		lbl.setFont(new Font("楷体",Font.BOLD,40));
		diag_message.setTitle("消息");
		diag_message.setSize(800, 600);
		diag_message.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
		diag_message.add(lb_message);
		diag_message.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		container.add(lb_name);
		lb_name.setBounds(250, 200, 50, 50);
		lb_name.setFont(new Font("黑体",Font.BOLD,20));
		container.add(lb_pass);
		lb_pass.setBounds(250, 300, 50, 50);
		lb_pass.setFont(new Font("黑体",Font.BOLD,20));
		container.add(tf_name);
		tf_name.setBounds(350, 200, 200, 50);
		tf_name.setFont(new Font("黑体",Font.BOLD,20));
		container.add(pf_pass);
		pf_pass.setBounds(350, 300, 200, 50);
		pf_pass.setFont(new Font("黑体",Font.BOLD,20));
		pf_pass.setEchoChar('*');
		container.add(bt_login);
		bt_login.setBounds(250, 400, 100, 50);
		bt_login.setFont(new Font("黑体",Font.BOLD,20));
		bt_login.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_login) {
					try {
						AdministratorTest.main(args);
					} catch (Exception e1) {
						e1.printStackTrace();
					}
					int f=0;
					for(int i=0;i<AdministratorTest.administratorArrayList.size();i++) {
						if((tf_name.getText()).equals(AdministratorTest.administratorArrayList.get(i).administratorAccount)&&(String.valueOf(pf_pass.getPassword())).equals(AdministratorTest.administratorArrayList.get(i).password)) {
							f=1;
							AdministratorTest.currentAdministratorAccount=AdministratorTest.administratorArrayList.get(i);
							tf_name.setText("");
							pf_pass.setText("");
							new AdministratorInterface();
							AdministratorInterface.main(args);
						}
					}
					if(f==0) {
						tf_name.setText("");
						pf_pass.setText("");
						diag_message.setLocationRelativeTo(null);
						diag_message.setVisible(true);
						lb_message.setText("请注意:您输入的管理员账号或密码有误,请检查后再试!");
						lb_message.setFont(new Font("楷体",Font.BOLD,20));
					}
				}
			}
		});
		container.add(bt_reset);
		bt_reset.setBounds(450, 400, 100, 50);
		bt_reset.setFont(new Font("黑体",Font.BOLD,20));
		bt_reset.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_reset) {
					tf_name.setText("");
					pf_pass.setText("");
				}
			}
		});
		container.add(bt_return);
		bt_return.setBounds(350, 500, 100, 50);
		bt_return.setFont(new Font("黑体",Font.BOLD,20));
		bt_return.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_return) {
					mainJFrame_2.dispose();
					MainInterface.main(args);
				}
			}
		});
		mainJFrame_2.setVisible(true);
	}
}

UserInterface.java

//文件名:UserInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
public class UserInterface {
	static FileReader fr;//FileReader类
	static FileWriter fw;//FileWriter类
	static SimpleDateFormat time;
	static Date date;
	//用户界面组件
	static JFrame mainJFrame_3=new JFrame();
	static JLabel lbl=new JLabel("ATM柜员机模拟程序——用户界面",JLabel.CENTER);
	static JDialog diag_message=new JDialog();
	static JLabel lb_message=new JLabel();
	//查询余额界面组件
	static JDialog diag_checkTheBalance=new JDialog(mainJFrame_3);
	static JLabel lb_checkTheBalance=new JLabel();
	static JButton bt_return_checkTheBalance=new JButton("返回");
	//取款界面组件
	static JDialog diag_withdrawMoney=new JDialog(mainJFrame_3);
	static JLabel lb_withdrawMoney=new JLabel();
	static JTextField tf_withdrawMoney=new JTextField(20);
	static JButton bt_determine_withdrawMoney=new JButton("确定");
	static JButton bt_return_withdrawMoney=new JButton("返回");
	//存款界面组件
	static JDialog diag_deposit=new JDialog(mainJFrame_3);
	static JLabel lb_deposit=new JLabel();
	static JTextField tf_deposit=new JTextField(20);
	static JButton bt_determine_deposit=new JButton("确定");
	static JButton bt_return_deposit=new JButton("返回");
	//转账界面组件
	static JDialog diag_transferAccounts=new JDialog(mainJFrame_3);
	static JLabel lb_transferAccounts=new JLabel();
	static JTextField tf_transferAccounts_name=new JTextField(20);
	static JTextField tf_transferAccounts_amount=new JTextField(20);
	static JButton bt_determine_transferAccounts=new JButton("确定");
	static JButton bt_return_transferAccounts=new JButton("返回");
	//转账确认界面组件
	static JDialog diag_transferAccounts_confirm=new JDialog(mainJFrame_3);
	static JLabel lb_transferAccounts_confirm_name=new JLabel();
	static JLabel lb_transferAccounts_confirm_amount=new JLabel();
	static JButton bt_transferAccounts_confirm_yes=new JButton("是");
	static JButton bt_transferAccounts_confirm_no=new JButton("否");
	//历史交易记录查询界面组件
	static JDialog diag_historicalTransactionQuery=new JDialog(mainJFrame_3);
	static JTextArea ta=new JTextArea(22,1);
	static JButton bt_return_historicalTransactionQuery=new JButton("返回");
	//修改密码界面组件
	static JDialog diag_changePassword=new JDialog(mainJFrame_3);
	static JTextField tf_changePassword_old=new JTextField(20);
	static JTextField tf_changePassword_new=new JTextField(20);
	static JTextField tf_changePassword_new_confirm=new JTextField(20);
	static JButton bt_determine_changePassword=new JButton("确定");
	static JButton bt_return_changePassword=new JButton("返回");
	//退卡界面组件
	static JDialog diag_refundCard=new JDialog(mainJFrame_3);
	static JButton bt_close=new JButton("关闭");
	static JButton bt_cancel=new JButton("取消");
	//用户界面组件
	static JButton bt_checkTheBalance=new JButton("查询余额");
	static JButton bt_withdrawMoney=new JButton("取款");
	static JButton bt_deposit=new JButton("存款");
	static JButton bt_transferAccounts=new JButton("转账");
	static JButton bt_historicalTransactionQuery=new JButton("历史交易记录查询");
	static JButton bt_changePassword=new JButton("修改密码");
	static JButton bt_refundCard=new JButton("退卡");
	public static void main(String[] args) {
		//用户界面
		mainJFrame_3.setTitle("ATM柜员机模拟程序——用户界面");
		/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
		mainJFrame_3.setBounds(0, 0, 800, 600);
		mainJFrame_3.setLocationRelativeTo(null);
		mainJFrame_3.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		Container container=mainJFrame_3.getContentPane();
		container.setLayout(null);
		container.add(lbl);
		lbl.setBounds(0, 75, 800, 50);
		lbl.setFont(new Font("楷体",Font.BOLD,40));
		diag_message.setTitle("消息");
		diag_message.setSize(800, 600);
		diag_message.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
		diag_message.add(lb_message);
		diag_message.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		//查询余额界面
		container.add(bt_checkTheBalance);
		bt_checkTheBalance.setBounds(0, 200, 200, 50);
		bt_checkTheBalance.setFont(new Font("黑体",Font.BOLD,20));
		bt_checkTheBalance.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_checkTheBalance) {
					time=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
					date=new Date();
					diag_checkTheBalance.setTitle("查询余额");
					diag_checkTheBalance.setSize(400, 300);
					diag_checkTheBalance.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
					diag_checkTheBalance.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_checkTheBalance.add(lb_checkTheBalance);
					lb_checkTheBalance.setText("您的余额为 "+UserTest.currentUserAccount.balance+" 元");
					lb_checkTheBalance.setFont(new Font("楷体",Font.BOLD,20));
					//记录操作
					try {
						fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt",true);
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {//"时 间\t\t\t\t操作\t\t余额\t\t备注\r\n"
						fw.write(time.format(date)+"\t\t查询余额\t\t\t"+UserTest.currentUserAccount.balance+"元\t\t无\r\n");
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.flush();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.close();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw=new FileWriter("historyOfAll.txt",true);
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.write(UserTest.currentUserAccount.userAccount+"\t\t"+time.format(date)+"\t\t查询余额\t\t\t无\t\t其余额"+UserTest.currentUserAccount.balance+"元\r\n");
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.flush();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.close();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					diag_checkTheBalance.add(bt_return_checkTheBalance);
					bt_return_checkTheBalance.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_checkTheBalance.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_checkTheBalance) {
								diag_checkTheBalance.dispose();
							}
						}
					});
					diag_checkTheBalance.setLocationRelativeTo(null);
					diag_checkTheBalance.setVisible(true);
				}
			}
		});
		//取款界面
		container.add(bt_withdrawMoney);
		bt_withdrawMoney.setBounds(0, 300, 200, 50);
		bt_withdrawMoney.setFont(new Font("黑体",Font.BOLD,20));
		bt_withdrawMoney.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_withdrawMoney) {
					diag_withdrawMoney.setTitle("取款");
					diag_withdrawMoney.setSize(400, 300);
					diag_withdrawMoney.setLayout(new FlowLayout(FlowLayout.CENTER,100,50));
					diag_withdrawMoney.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_withdrawMoney.add(lb_withdrawMoney);
					lb_withdrawMoney.setText("您的余额为 "+UserTest.currentUserAccount.balance+" 元");
					lb_withdrawMoney.setFont(new Font("楷体",Font.BOLD,20));
					diag_withdrawMoney.add(tf_withdrawMoney);
					tf_withdrawMoney.setText("请输入取款金额");
					tf_withdrawMoney.setFont(new Font("楷体",Font.BOLD,20));
					diag_withdrawMoney.add(bt_determine_withdrawMoney);
					bt_determine_withdrawMoney.setFont(new Font("黑体",Font.BOLD,15));
					bt_determine_withdrawMoney.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_determine_withdrawMoney) {
								//每次取款金额为100的倍数
								if(Float.parseFloat(tf_withdrawMoney.getText())%100!=0) {
									diag_withdrawMoney.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:每次取款金额应为100的倍数,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//每次取款总额不超过5000元
								else if(Float.parseFloat(tf_withdrawMoney.getText())>5000.00) {
									diag_withdrawMoney.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:每次取款总额不得超过 5000.00 元,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//支取金额不允许透支
								else if(Float.parseFloat(tf_withdrawMoney.getText())>UserTest.currentUserAccount.balance) {
									diag_withdrawMoney.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:支取金额不允许透支,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//非正数
								else if(Float.parseFloat(tf_withdrawMoney.getText())<=0) {
									diag_withdrawMoney.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:您的输入有误,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//成功取款
								else {
									time=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
									date=new Date();
									UserTest.currentUserAccount.balance-=Float.parseFloat(tf_withdrawMoney.getText());
									//记录操作
									try {
										fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {//"时 间\t\t\t\t操作\t\t余额\t\t备注\r\n"
										fw.write(time.format(date)+"\t\t取款"+Float.parseFloat(tf_withdrawMoney.getText())+"元\t\t"+UserTest.currentUserAccount.balance+"元\t\t无\r\n");
									} catch (NumberFormatException | IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("historyOfAll.txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write(UserTest.currentUserAccount.userAccount+"\t\t"+time.format(date)+"\t\t取款"+Float.parseFloat(tf_withdrawMoney.getText())+"元\t\t无\t\t其余额"+UserTest.currentUserAccount.balance+"元\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fr=new FileReader("administratorFile.txt");
									} catch (FileNotFoundException e1) {
										e1.printStackTrace();
									}
									BufferedReader br=new BufferedReader(fr);
									String temp="";
									String[] tempString=new String[5];
									String A=null;
									String B=null;
									String C=null;
									try {
										while((temp=br.readLine())!=null) {
											tempString=temp.split("\\s+");
											A=tempString[0];
											B=tempString[1];
											C=tempString[2];
										}
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									float balance=Float.parseFloat(C)-Float.parseFloat(tf_withdrawMoney.getText());
									try {
										fw=new FileWriter("administratorFile.txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									StringBuilder sb=new StringBuilder();
									sb.append(A+" "+B+" "+balance+"\r\n");
									try {
										fw.write(sb.toString());
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("recentFund.txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write(time.format(date)+"\t\t支出"+Float.parseFloat(tf_withdrawMoney.getText())+"元\t\t至"+UserTest.currentUserAccount.userAccount+"\t\t本机余额"+balance+"元\r\n");
									} catch (NumberFormatException | IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									//更新UserFile
									try {
										UserTest.userArrayListWrite();
									} catch (Exception e1) {
										e1.printStackTrace();
									}
									diag_withdrawMoney.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:取款成功!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
							}
						}
					});
					diag_withdrawMoney.add(bt_return_withdrawMoney);
					bt_return_withdrawMoney.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_withdrawMoney.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_withdrawMoney) {
								diag_withdrawMoney.dispose();
							}
						}
					});
					diag_withdrawMoney.setLocationRelativeTo(null);
					diag_withdrawMoney.setVisible(true);
				}
			}
		});
		//存款界面
		container.add(bt_deposit);
		bt_deposit.setBounds(0, 400, 200, 50);
		bt_deposit.setFont(new Font("黑体",Font.BOLD,20));
		bt_deposit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_deposit) {
					diag_deposit.setTitle("存款");
					diag_deposit.setSize(400, 300);
					diag_deposit.setLayout(new FlowLayout(FlowLayout.CENTER,100,50));
					diag_deposit.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_deposit.add(lb_deposit);
					lb_deposit.setText("您的余额为 "+UserTest.currentUserAccount.balance+" 元");
					lb_deposit.setFont(new Font("楷体",Font.BOLD,20));
					diag_deposit.add(tf_deposit);
					tf_deposit.setText("请输入存款金额");
					tf_deposit.setFont(new Font("楷体",Font.BOLD,20));
					diag_deposit.add(bt_determine_deposit);
					bt_determine_deposit.setFont(new Font("黑体",Font.BOLD,15));
					bt_determine_deposit.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_determine_deposit) {
								//每次存款金额为100的倍数
								if(Float.parseFloat(tf_deposit.getText())%100!=0) {
									diag_deposit.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:每次存款金额应为100的倍数,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//非正数
								else if(Float.parseFloat(tf_deposit.getText())<=0) {
									diag_deposit.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:您的输入有误,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//成功存款
								else {
									time=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
									date=new Date();
									UserTest.currentUserAccount.balance+=Float.parseFloat(tf_deposit.getText());
									//记录操作
									try {
										fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {//"时 间\t\t\t\t操作\t\t余额\t\t备注\r\n"
										fw.write(time.format(date)+"\t\t存款"+Float.parseFloat(tf_deposit.getText())+"元\t\t"+UserTest.currentUserAccount.balance+"元\t\t无\r\n");
									} catch (NumberFormatException | IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("historyOfAll.txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write(UserTest.currentUserAccount.userAccount+"\t\t"+time.format(date)+"\t\t存款"+Float.parseFloat(tf_deposit.getText())+"元\t\t无\t\t其余额"+UserTest.currentUserAccount.balance+"元\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fr=new FileReader("administratorFile.txt");
									} catch (FileNotFoundException e1) {
										e1.printStackTrace();
									}
									BufferedReader br=new BufferedReader(fr);
									String temp="";
									String[] tempString=new String[5];
									String A=null;
									String B=null;
									String C=null;
									try {
										while((temp=br.readLine())!=null) {
											tempString=temp.split("\\s+");
											A=tempString[0];
											B=tempString[1];
											C=tempString[2];
										}
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									float balance=Float.parseFloat(C)+Float.parseFloat(tf_deposit.getText());
									try {
										fw=new FileWriter("administratorFile.txt");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									StringBuilder sb=new StringBuilder();
									sb.append(A+" "+B+" "+balance+"\r\n");
									try {
										fw.write(sb.toString());
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("recentFund.txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write(time.format(date)+"\t\t收入"+Float.parseFloat(tf_deposit.getText())+"元\t\t来自"+UserTest.currentUserAccount.userAccount+"\t\t本机余额"+balance+"元\r\n");
									} catch (NumberFormatException | IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									//更新UserFile
									try {
										UserTest.userArrayListWrite();
									} catch (Exception e1) {
										e1.printStackTrace();
									}
									diag_deposit.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:存款成功!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
							}
						}
					});
					diag_deposit.add(bt_return_deposit);
					bt_return_deposit.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_deposit.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_deposit) {
								diag_deposit.dispose();
							}
						}
					});
					diag_deposit.setLocationRelativeTo(null);
					diag_deposit.setVisible(true);
				}
			}
		});
		//转账界面
		container.add(bt_transferAccounts);
		bt_transferAccounts.setBounds(0, 500, 200, 50);
		bt_transferAccounts.setFont(new Font("黑体",Font.BOLD,20));
		bt_transferAccounts.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_transferAccounts) {
					diag_transferAccounts.setTitle("转账");
					diag_transferAccounts.setSize(400, 300);
					diag_transferAccounts.setLayout(new FlowLayout(FlowLayout.CENTER,100,25));
					diag_transferAccounts.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_transferAccounts.add(lb_transferAccounts);
					lb_transferAccounts.setText("您的余额为 "+UserTest.currentUserAccount.balance+" 元");
					lb_transferAccounts.setFont(new Font("楷体",Font.BOLD,20));
					diag_transferAccounts.add(tf_transferAccounts_name);
					tf_transferAccounts_name.setText("请输入转账账号");
					tf_transferAccounts_name.setFont(new Font("楷体",Font.BOLD,20));
					diag_transferAccounts.add(tf_transferAccounts_amount);
					tf_transferAccounts_amount.setText("请输入转账金额");
					tf_transferAccounts_amount.setFont(new Font("楷体",Font.BOLD,20));
					diag_transferAccounts.add(bt_determine_transferAccounts);
					bt_determine_transferAccounts.setFont(new Font("黑体",Font.BOLD,15));
					bt_determine_transferAccounts.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_determine_transferAccounts) {
								int f=0;
								for(int i=0;i<UserTest.userArrayList.size();i++) {
									if((tf_transferAccounts_name.getText()).equals(UserTest.userArrayList.get(i).userAccount)){
										f=1;
										UserTest.currentUserAccount_1.userAccount=UserTest.userArrayList.get(i).userAccount;
										UserTest.currentUserAccount_1.balance=UserTest.userArrayList.get(i).balance;
									}
								}
								//银行卡不存在
								if(f==0) {
									diag_transferAccounts.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:对方账号不存在,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//每次转账总额不超过10000元
								else if(Float.parseFloat(tf_transferAccounts_amount.getText())>10000.00) {
									diag_transferAccounts.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:每次转账总额不得超过 10000.00 元,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//余额不足
								else if(f==1&&(Float.parseFloat(tf_transferAccounts_amount.getText())>UserTest.currentUserAccount.balance)) {
									diag_transferAccounts.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:您的余额不足,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//非正数
								else if(f==1&&(Float.parseFloat(tf_transferAccounts_amount.getText())<=0)) {
									diag_transferAccounts.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:您的输入有误,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//不得向自己转账
								else if(f==0&&(tf_transferAccounts_name.getText()==UserTest.currentUserAccount.userAccount)) {
									diag_transferAccounts.dispose();
									diag_message.setLocationRelativeTo(null);
									diag_message.setVisible(true);
									lb_message.setText("请注意:您的输入有误,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								//待成功转账
								else {
									String amount=tf_transferAccounts_amount.getText();
									String name=tf_transferAccounts_name.getText();
									lb_transferAccounts_confirm_name.setText("是否确认转账 "+amount+" 元");
									lb_transferAccounts_confirm_amount.setText("至 "+name+" 账户");
									//转账确认界面
									diag_transferAccounts_confirm.setTitle("转账确认");
									diag_transferAccounts_confirm.setSize(400, 300);
									diag_transferAccounts_confirm.setLayout(new FlowLayout(FlowLayout.CENTER,100,50));
									diag_transferAccounts_confirm.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
									diag_transferAccounts_confirm.add(lb_transferAccounts_confirm_name);
									lb_transferAccounts_confirm_name.setFont(new Font("楷体",Font.BOLD,20));
									diag_transferAccounts_confirm.add(lb_transferAccounts_confirm_amount);
									lb_transferAccounts_confirm_amount.setFont(new Font("楷体",Font.BOLD,20));
									diag_transferAccounts_confirm.add(bt_transferAccounts_confirm_yes);
									bt_transferAccounts_confirm_yes.setFont(new Font("黑体",Font.BOLD,15));
									bt_transferAccounts_confirm_yes.addActionListener(new ActionListener() {
										public void actionPerformed(ActionEvent e) {
											JButton bt=(JButton)e.getSource();
											//成功转账
											if(bt==bt_transferAccounts_confirm_yes) {
												time=new SimpleDateFormat("yyyy年MM月dd日");
												date=new Date();
												try {
													fr=new FileReader(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
												} catch (FileNotFoundException e1) {
													e1.printStackTrace();
												}
												BufferedReader br_1=new BufferedReader(fr);
												String temp_1="";
												String[] tempString_1=new String[2];
												String A_1=null;
												try {
													while((temp_1=br_1.readLine())!=null) {
														tempString_1=temp_1.split("\\s+");
														A_1=tempString_1[0];
													}
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												float transfer_1=Float.parseFloat(A_1);
												try {
													br_1.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												try {
													fr.close();
												} catch (IOException e1) {
													e1.printStackTrace();
												}
												if(transfer_1+Float.parseFloat(tf_transferAccounts_amount.getText())>=10000) {
													diag_transferAccounts_confirm.dispose();
													diag_transferAccounts.dispose();
													diag_message.setLocationRelativeTo(null);
													diag_message.setVisible(true);
													lb_message.setText("请注意:当前账号当日转账超过 10000.00 元,暂时无法转账,请明日再试!");
													lb_message.setFont(new Font("楷体",Font.BOLD,20));
												}
												else {
													time=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
													date=new Date();
													UserTest.currentUserAccount.balance-=Float.parseFloat(tf_transferAccounts_amount.getText());
													UserTest.currentUserAccount_1.balance+=Float.parseFloat(tf_transferAccounts_amount.getText());
													//记录操作01
													try {
														fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt",true);
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {//"时 间\t\t\t\t操作\t\t余额\t\t备注\r\n"
														fw.write(time.format(date)+"\t\t转账"+Float.parseFloat(tf_transferAccounts_amount.getText())+"元\t\t"+UserTest.currentUserAccount.balance+"元\t\t至"+UserTest.currentUserAccount_1.userAccount+"\r\n");
													} catch (NumberFormatException | IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.flush();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													UserTest.currentUserFile=new File(UserTest.currentUserAccount_1.userAccount+".txt");
													if(!UserTest.currentUserFile.exists()) {
														try {
															UserTest.currentUserFile.createNewFile();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw=new FileWriter(UserTest.currentUserAccount_1.userAccount+".txt");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.write("时 间\t\t\t\t操作\t\t\t余额\t\t备注\r\n");
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.flush();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
														try {
															fw.close();
														} catch (IOException e1) {
															e1.printStackTrace();
														}
													}
													//记录操作02
													try {
														fw=new FileWriter(UserTest.currentUserAccount_1.userAccount+".txt",true);
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {//"时间\t\t\t\t操作\t\t余额\t\t备注\r\n"
														fw.write(time.format(date)+"\t\t收到转账"+Float.parseFloat(tf_transferAccounts_amount.getText())+"元\t\t"+UserTest.currentUserAccount_1.balance+"元\t来自"+UserTest.currentUserAccount.userAccount+"\r\n");
													} catch (NumberFormatException | IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.flush();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw=new FileWriter("historyOfAll.txt",true);
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.write(UserTest.currentUserAccount.userAccount+"\t\t"+time.format(date)+"\t\t转账"+Float.parseFloat(tf_transferAccounts_amount.getText())+"元\t\t至"+UserTest.currentUserAccount_1.userAccount+"\t\t其余额"+UserTest.currentUserAccount.balance+"元\r\n");
														fw.write(UserTest.currentUserAccount_1.userAccount+"\t\t"+time.format(date)+"\t\t收到转账"+Float.parseFloat(tf_transferAccounts_amount.getText())+"元\t\t来自"+UserTest.currentUserAccount.userAccount+"\t\t其余额"+UserTest.currentUserAccount_1.balance+"元\r\n");
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.flush();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													//更新UserFile
													for(int i=0;i<UserTest.userArrayList.size();i++) {
														if(UserTest.userArrayList.get(i).userAccount.equals(UserTest.currentUserAccount_1.userAccount)) {
															UserTest.userArrayList.get(i).balance=UserTest.currentUserAccount_1.balance;
														}
													}
													try {
														UserTest.userArrayListWrite();
													} catch (Exception e1) {
														e1.printStackTrace();
													}
													time=new SimpleDateFormat("yyyy年MM月dd日");
													date=new Date();
													try {
														fr=new FileReader(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
													} catch (FileNotFoundException e1) {
														e1.printStackTrace();
													}
													BufferedReader br=new BufferedReader(fr);
													String temp="";
													String[] tempString=new String[2];
													String A=null;
													try {
														while((temp=br.readLine())!=null) {
															tempString=temp.split("\\s+");
															A=tempString[0];
														}
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													float transfer=Float.parseFloat(A);
													try {
														br.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fr.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													transfer+=Float.parseFloat(tf_transferAccounts_amount.getText());
													try {
														fw=new FileWriter(UserTest.currentUserAccount.userAccount+" "+time.format(date)+"transfer.txt");
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.write(transfer+"");
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.flush();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													try {
														fw.close();
													} catch (IOException e1) {
														e1.printStackTrace();
													}
													diag_transferAccounts_confirm.dispose();
													diag_transferAccounts.dispose();
													diag_message.setLocationRelativeTo(null);
													diag_message.setVisible(true);
													lb_message.setText("请注意:转账成功!");
													lb_message.setFont(new Font("楷体",Font.BOLD,20));
												}
											}
										}
									});
									diag_transferAccounts_confirm.add(bt_transferAccounts_confirm_no);
									bt_transferAccounts_confirm_no.setFont(new Font("黑体",Font.BOLD,15));
									bt_transferAccounts_confirm_no.addActionListener(new ActionListener() {
										public void actionPerformed(ActionEvent e) {
											JButton bt=(JButton)e.getSource();
											if(bt==bt_transferAccounts_confirm_no) {
												diag_transferAccounts_confirm.dispose();
											}
										}
									});
									diag_transferAccounts_confirm.setLocationRelativeTo(null);
									diag_transferAccounts_confirm.setVisible(true);
								}
							}
						}
					});
					diag_transferAccounts.add(bt_return_transferAccounts);
					bt_return_transferAccounts.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_transferAccounts.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_transferAccounts) {
								diag_transferAccounts.dispose();
							}
						}
					});
					diag_transferAccounts.setLocationRelativeTo(null);
					diag_transferAccounts.setVisible(true);
				}
			}
		});
		//历史交易记录查询界面
		container.add(bt_historicalTransactionQuery);
		bt_historicalTransactionQuery.setBounds(585, 250, 200, 50);
		bt_historicalTransactionQuery.setFont(new Font("黑体",Font.BOLD,19));
		bt_historicalTransactionQuery.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_historicalTransactionQuery) {
					diag_historicalTransactionQuery.setTitle("历史交易记录查询");
					diag_historicalTransactionQuery.setSize(800, 600);
					diag_historicalTransactionQuery.setLayout(null);
					diag_historicalTransactionQuery.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_historicalTransactionQuery.add(ta);
					ta.setBounds(0, 0, 800, 500);
					try {
						fr=new FileReader(UserTest.currentUserAccount.userAccount+".txt");
					} catch (FileNotFoundException e1) {
						e1.printStackTrace();
					}
					BufferedReader br=new BufferedReader(fr);
					String temp="";
					String[] tempString=new String[9];
					try {
						while((temp=br.readLine())!=null) {
							tempString=temp.split("\\s+");
							String A=tempString[0];
							String B=tempString[1];
							String C=tempString[2];
							String D=tempString[3];
							String E=tempString[4];
							if(A.equals("时")) {
								ta.append("\r\n  "+A+B+"\t\t\t\t"+C+"\t\t"+D+"\t\t"+E+"\r\n\r\n");
							}
							else if(C.equals("查询余额")) {}
							else if(C.equals("历史交易记录查询")) {}
							else if(C.equals("修改密码")) {}
							else {
								ta.append("  "+A+" "+B+"\t"+C+"\t"+D+"\t"+E+"\r\n");
							}
						}
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						br.close();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fr.close();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					time=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
					date=new Date();
					//记录操作
					try {
						fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt",true);
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {//"时 间\t\t\t\t操作\t\t余额\t\t备注\r\n"
						fw.write(time.format(date)+"\t\t历史交易记录查询\t\t"+UserTest.currentUserAccount.balance+"元\t\t无\r\n");
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.flush();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.close();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw=new FileWriter("historyOfAll.txt",true);
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.write(UserTest.currentUserAccount.userAccount+"\t\t"+time.format(date)+"\t\t历史记录查询\t\t无\t\t其余额"+UserTest.currentUserAccount.balance+"元\r\n");
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.flush();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					try {
						fw.close();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					ta.setEditable(false);
					ta.setFont(new Font("黑体",Font.BOLD,15));
					diag_historicalTransactionQuery.add(bt_return_historicalTransactionQuery);
					bt_return_historicalTransactionQuery.setBounds(367, 520, 66, 28);
					bt_return_historicalTransactionQuery.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_historicalTransactionQuery.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_historicalTransactionQuery) {
								diag_historicalTransactionQuery.dispose();
								ta.setText("");
							}
						}
					});
					diag_historicalTransactionQuery.setLocationRelativeTo(null);
					diag_historicalTransactionQuery.setVisible(true);
				}
			}
		});
		//修改密码界面
		container.add(bt_changePassword);
		bt_changePassword.setBounds(585, 350, 200, 50);
		bt_changePassword.setFont(new Font("黑体",Font.BOLD,20));
		bt_changePassword.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_changePassword) {
					diag_changePassword.setTitle("修改密码");
					diag_changePassword.setSize(400, 300);
					diag_changePassword.setLayout(new FlowLayout(FlowLayout.CENTER,100,25));
					diag_changePassword.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_changePassword.add(tf_changePassword_old);
					tf_changePassword_old.setText("请输入旧密码");
					tf_changePassword_old.setFont(new Font("楷体",Font.BOLD,20));
					diag_changePassword.add(tf_changePassword_new);
					tf_changePassword_new.setText("请输入新密码");
					tf_changePassword_new.setFont(new Font("楷体",Font.BOLD,20));
					diag_changePassword.add(tf_changePassword_new_confirm);
					tf_changePassword_new_confirm.setText("请确认新密码");
					tf_changePassword_new_confirm.setFont(new Font("楷体",Font.BOLD,20));
					diag_changePassword.add(bt_determine_changePassword);
					bt_determine_changePassword.setFont(new Font("黑体",Font.BOLD,15));
					bt_determine_changePassword.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_determine_changePassword) {
								String old=tf_changePassword_old.getText();
								String new_input=tf_changePassword_new.getText();
								String new_confirm=tf_changePassword_new_confirm.getText();
								try {
									fr=new FileReader("userFile.txt");
								} catch (FileNotFoundException e1) {
									e1.printStackTrace();
								}
								BufferedReader br=new BufferedReader(fr);
								String temp="";
								String[] tempString=new String[5];
								try {
									while((temp=br.readLine())!=null) {
										tempString=temp.split("\\s+");
										if(tempString[0].equals(UserTest.currentUserAccount.userAccount)) {
											UserTest.currentUserAccount.password=tempString[1];
										}
									}
								} catch (IOException e1) {
									e1.printStackTrace();
								}
								try {
									br.close();
								} catch (IOException e1) {
									e1.printStackTrace();
								}
								try {
									fr.close();
								} catch (IOException e1) {
									e1.printStackTrace();
								}
								if(old.equals("请输入旧密码")) {//未输入旧密码
									lb_message.setText("请注意:请输入旧密码!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else if(new_input.equals("请输入新密码")) {//未输入新密码
									lb_message.setText("请注意:请输入新密码!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else if(new_confirm.equals("请确认新密码")) {//未确认新密码
									lb_message.setText("请注意:请确认新密码!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else if(!old.equals(UserTest.currentUserAccount.password)) {//旧密码输入有误
									lb_message.setText("请注意:您输入的旧密码有误,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else if(new_input.equals(old)) {//新密码与旧密码一致
									lb_message.setText("请注意:您输入的新密码与旧密码一致,无法修改!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else if(!new_confirm.equals(new_input)) {//两次输入新密码不一致
									lb_message.setText("请注意:您两次输入的新密码不一致,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else if(new_input.length()!=6) {//新密码不为6位
									lb_message.setText("请注意:您输入的新密码不为6位,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else if(new_input.equals("000000")||new_input.equals("111111")||new_input.equals("222222")||new_input.equals("333333")||new_input.equals("444444")||new_input.equals("555555")||new_input.equals("666666")||new_input.equals("777777")||new_input.equals("888888")||new_input.equals("999999")) {//新密码出现6位完全相同的数字
									lb_message.setText("请注意:您输入的新密码不得出现6位完全相同的数字,请检查后再试!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
								}
								else {//成功修改密码
									time=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
									date=new Date();
									UserTest.currentUserAccount.password=new_confirm;
									//记录操作
									try {
										fw=new FileWriter(UserTest.currentUserAccount.userAccount+".txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {//"时 间\t\t\t\t操作\t\t余额\t\t备注\r\n"
										fw.write(time.format(date)+"\t\t修改密码\t\t\t"+UserTest.currentUserAccount.balance+"元\t\t无\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw=new FileWriter("historyOfAll.txt",true);
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.write(UserTest.currentUserAccount.userAccount+"\t\t"+time.format(date)+"\t\t修改密码\t\t\t无\t\t其余额"+UserTest.currentUserAccount.balance+"元\r\n");
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.flush();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									try {
										fw.close();
									} catch (IOException e1) {
										e1.printStackTrace();
									}
									//更新UserFile
									for(int i=0;i<UserTest.userArrayList.size();i++) {
										if(UserTest.userArrayList.get(i).userAccount.equals(UserTest.currentUserAccount.userAccount)) {
											UserTest.userArrayList.get(i).password=UserTest.currentUserAccount.password;
										}
									}
									try {
										UserTest.userArrayListWrite();
									} catch (Exception e1) {
										e1.printStackTrace();
									}
									lb_message.setText("请注意:修改成功,请重新登录!");
									lb_message.setFont(new Font("楷体",Font.BOLD,20));
									diag_message.addWindowListener(new WindowListener() {
										@Override
										public void windowOpened(WindowEvent e) {
										}
										@Override
										public void windowClosing(WindowEvent e) {
											System.exit(0);
										}
										@Override
										public void windowClosed(WindowEvent e) {
											System.exit(0);
										}
										@Override
										public void windowIconified(WindowEvent e) {	
										}
										@Override
										public void windowDeiconified(WindowEvent e) {
										}
										@Override
										public void windowActivated(WindowEvent e) {
										}
										@Override
										public void windowDeactivated(WindowEvent e) {
										}
									});
								}
								diag_changePassword.dispose();
								diag_message.setLocationRelativeTo(null);
								diag_message.setVisible(true);
							}
						}
					});
					diag_changePassword.add(bt_return_changePassword);
					bt_return_changePassword.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_changePassword.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_changePassword) {
								diag_changePassword.dispose();
							}
						}
					});
					diag_changePassword.setLocationRelativeTo(null);
					diag_changePassword.setVisible(true);
				}
			}
		});
		//退卡界面
		container.add(bt_refundCard);
		bt_refundCard.setBounds(585, 450, 200, 50);
		bt_refundCard.setFont(new Font("黑体",Font.BOLD,20));
		bt_refundCard.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_refundCard) {
					diag_refundCard.setTitle("退卡");
					diag_refundCard.setSize(400, 300);
					diag_refundCard.setLayout(new FlowLayout(FlowLayout.CENTER,50,100));
					diag_refundCard.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_refundCard.add(bt_close);
					bt_close.setFont(new Font("黑体",Font.BOLD,15));
					bt_close.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_close) {
								System.exit(0);
							}
						}
					});
					diag_refundCard.add(bt_cancel);
					bt_cancel.setFont(new Font("黑体",Font.BOLD,15));
					bt_cancel.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_cancel) {
								diag_refundCard.dispose();
							}
						}
					});
					diag_refundCard.setLocationRelativeTo(null);
					diag_refundCard.setVisible(true);
				}
			}
		});
		//用户界面
		mainJFrame_3.setVisible(true);
	}
}

AdministratorInterface.java

//文件名:AdministratorInterface.java
package ATM;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
public class AdministratorInterface {
	static FileReader fr;//FileReader类
	static FileWriter fw;//FileWriter类
	static SimpleDateFormat time;
	static Date date;
	static JFrame mainJFrame_4=new JFrame();
	static JLabel lbl=new JLabel("ATM柜员机模拟程序——管理员界面",JLabel.CENTER);
	static JDialog diag_message=new JDialog();
	static JLabel lb_message=new JLabel();
	static JDialog diag_recentFund=new JDialog(mainJFrame_4);
	static JTextArea ta_recentFund=new JTextArea();
	static JButton bt_return_recentFund=new JButton("返回");
	static JDialog diag_historyOfAll=new JDialog(mainJFrame_4);
	static JTextArea ta_historyOfAll=new JTextArea();
	static JButton bt_return_historyOfAll=new JButton("返回");
	static JDialog diag_userAccountUnlock=new JDialog(mainJFrame_4);
	static JTextArea ta_userAccountUnlock=new JTextArea();
	static JButton bt_unlock_userAccountUnlock=new JButton("全部解锁");
	static JButton bt_return_userAccountUnlock=new JButton("返回");
	static JDialog diag_signOut=new JDialog(mainJFrame_4);
	static JButton bt_close=new JButton("关闭");
	static JButton bt_cancel=new JButton("取消");
	static JButton bt_recentFund=new JButton("本机近期资金出入明细");
	static JButton bt_historyOfAll=new JButton("本机所有账户的历史记录");
	static JButton bt_userAccountUnlock=new JButton("用户账号解锁");
	static JButton bt_signOut=new JButton("退出");
	public static void main(String[] args) {
		//管理员界面
		mainJFrame_4.setTitle("ATM柜员机模拟程序——管理员界面");
		/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
		mainJFrame_4.setBounds(0, 0, 800, 600);
		mainJFrame_4.setLocationRelativeTo(null);
		mainJFrame_4.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		Container container=mainJFrame_4.getContentPane();
		container.setLayout(null);
		container.add(lbl);
		lbl.setBounds(0, 75, 800, 50);
		lbl.setFont(new Font("楷体",Font.BOLD,40));
		diag_message.setTitle("消息");
		diag_message.setSize(1200, 600);
		diag_message.setLayout(new FlowLayout(FlowLayout.CENTER,100,100));
		diag_message.add(lb_message);
		diag_message.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		//本机近期资金出入明细界面
		container.add(bt_recentFund);
		bt_recentFund.setBounds(300, 200, 200, 50);
		bt_recentFund.setFont(new Font("黑体",Font.BOLD,15));
		bt_recentFund.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_recentFund) {
					diag_recentFund.setTitle("本机近期资金出入明细");
					diag_recentFund.setSize(1200, 600);
					diag_recentFund.setLayout(null);
					diag_recentFund.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_recentFund.add(ta_recentFund);
					ta_recentFund.setBounds(0, 0, 1200, 500);
					File recentFund=new File("recentFund.txt");
					if(!recentFund.exists()) {
						try {
							recentFund.createNewFile();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw=new FileWriter("recentFund.txt");
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.write("时 间\t\t\t\t操作\t\t\t备 注\r\n");
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.flush();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.close();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
					}
					try {
						fr=new FileReader("recentFund.txt");
					} catch (FileNotFoundException e1) {
						e1.printStackTrace();
					}
					BufferedReader br=new BufferedReader(fr);
					String temp="";
					String[] tempString=new String[9];
					try {
						while((temp=br.readLine())!=null) {
							tempString=temp.split("\\s+");
							String A=tempString[0];
							String B=tempString[1];
							String C=tempString[2];
							String D=tempString[3];
							String E=tempString[4];
							if(A.equals("时")) {
								ta_recentFund.append("\r\n\t"+A+""+B+"\t\t\t\t"+C+"\t\t\t"+D+""+E+"\r\n\r\n");
							}
							else {
								ta_recentFund.append("\t"+A+" "+B+"\t"+C+"\t\t"+D+"    "+E+"\r\n");
							}
						}
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					ta_recentFund.setEditable(false);
					ta_recentFund.setFont(new Font("黑体",Font.BOLD,15));
					diag_recentFund.add(bt_return_recentFund);
					bt_return_recentFund.setBounds(567, 520, 66, 28);
					bt_return_recentFund.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_recentFund.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_recentFund) {
								diag_recentFund.dispose();
								ta_recentFund.setText("");
							}
						}
					});
					diag_recentFund.setLocationRelativeTo(null);
					diag_recentFund.setVisible(true);
				}
			}
		});
		//本机所有账户的历史记录界面
		container.add(bt_historyOfAll);
		bt_historyOfAll.setBounds(300, 300, 200, 50);
		bt_historyOfAll.setFont(new Font("黑体",Font.BOLD,14));
		bt_historyOfAll.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_historyOfAll) {
					diag_historyOfAll.setTitle("本机所有账户的历史记录");
					diag_historyOfAll.setSize(1200, 600);
					diag_historyOfAll.setLayout(null);
					diag_historyOfAll.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_historyOfAll.add(ta_historyOfAll);
					ta_historyOfAll.setBounds(0, 0, 1200, 500);
					File historyOfAll=new File("historyOfAll.txt");
					if(!historyOfAll.exists()) {
						try {
							historyOfAll.createNewFile();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw=new FileWriter("historyOfAll.txt");
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.write("用户账号\t\t\t时 间\t\t\t\t操作\t\t\t备 注\r\n");
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.flush();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.close();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
					}
					try {
						fr=new FileReader("historyOfAll.txt");
					} catch (FileNotFoundException e1) {
						e1.printStackTrace();
					}
					BufferedReader br=new BufferedReader(fr);
					String temp="";
					String[] tempString=new String[11];
					try {
						while((temp=br.readLine())!=null) {
							tempString=temp.split("\\s+");
							String A=tempString[0];
							String B=tempString[1];
							String C=tempString[2];
							String D=tempString[3];
							String E=tempString[4];
							String F=tempString[5];
							if(A.equals("用户账号")) {
								ta_historyOfAll.append("\r\n\t"+A+"\t\t\t"+B+""+C+"\t\t\t\t"+D+"\t\t\t"+E+""+F+"\r\n\r\n");
							}
							else if(D.equals("查询余额")) {
								ta_historyOfAll.append("\t"+A+"\t"+B+" "+C+"\t"+D+"\t\t\t"+E+"    "+F+"\r\n");
							}
							else if(D.equals("修改密码")) {
								ta_historyOfAll.append("\t"+A+"\t"+B+" "+C+"\t"+D+"\t\t\t"+E+"    "+F+"\r\n");
							}
							else {
								ta_historyOfAll.append("\t"+A+"\t"+B+" "+C+"\t"+D+"\t\t"+E+"    "+F+"\r\n");
							}
						}
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					ta_historyOfAll.setEditable(false);
					ta_historyOfAll.setFont(new Font("黑体",Font.BOLD,15));
					diag_historyOfAll.add(bt_return_historyOfAll);
					bt_return_historyOfAll.setBounds(567, 520, 66, 28);
					bt_return_historyOfAll.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_historyOfAll.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_historyOfAll) {
								diag_historyOfAll.dispose();
								ta_historyOfAll.setText("");
							}
						}
					});
					diag_historyOfAll.setLocationRelativeTo(null);
					diag_historyOfAll.setVisible(true);
				}
			}
		});
		//用户账号解锁界面
		container.add(bt_userAccountUnlock);
		bt_userAccountUnlock.setBounds(300, 400, 200, 50);
		bt_userAccountUnlock.setFont(new Font("黑体",Font.BOLD,20));
		bt_userAccountUnlock.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_userAccountUnlock) {
					diag_userAccountUnlock.setTitle("用户账号解锁");
					diag_userAccountUnlock.setSize(1200, 600);
					diag_userAccountUnlock.setLayout(null);
					diag_userAccountUnlock.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
					diag_userAccountUnlock.add(ta_userAccountUnlock);
					ta_userAccountUnlock.setBounds(0, 0, 1200, 500);
					File unlock=new File("unlock.txt");
					if(!unlock.exists()) {
						try {
							unlock.createNewFile();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw=new FileWriter("unlock.txt");
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.write("被锁定 用户账号\t时 间\r\n");
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.flush();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
						try {
							fw.close();
						} catch (IOException e1) {
							e1.printStackTrace();
						}
					}
					try {
						fr=new FileReader("unlock.txt");
					} catch (FileNotFoundException e1) {
						e1.printStackTrace();
					}
					BufferedReader br=new BufferedReader(fr);
					String temp="";
					String[] tempString=new String[7];
					String A=null;
					String B=null;
					String C=null;
					String D=null;
					try {
						while((temp=br.readLine())!=null) {
							tempString=temp.split("\\s+");
							A=tempString[0];
							B=tempString[1];
							C=tempString[2];
							D=tempString[3];
							if(A.equals("被锁定")) {
								ta_userAccountUnlock.append("\r\n\t"+A+""+B+"\t\t"+C+""+D+"\r\n");
							}
							else {
								ta_userAccountUnlock.append("\r\n\t"+A+"\t"+D+"\t"+C+"\t"+B+"\r\n");
							}
						}
					} catch (IOException e1) {
						e1.printStackTrace();
					}
					ta_userAccountUnlock.setEditable(false);
					ta_userAccountUnlock.setFont(new Font("黑体",Font.BOLD,15));
					diag_userAccountUnlock.add(bt_unlock_userAccountUnlock);
					bt_unlock_userAccountUnlock.setBounds(450, 520, 100, 28);
					bt_unlock_userAccountUnlock.setFont(new Font("黑体",Font.BOLD,15));
					bt_unlock_userAccountUnlock.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_unlock_userAccountUnlock) {
								try {
									fr=new FileReader("unlock.txt");
								} catch (FileNotFoundException e1) {
									e1.printStackTrace();
								}
								BufferedReader br=new BufferedReader(fr);
								String temp="";
								String[] tempString=new String[3];
								String A=null;
								String B=null;
								String C=null;
								String D=null;
								try {
									while((temp=br.readLine())!=null) {
										tempString=temp.split("\\s+");
										A=tempString[0];
										B=tempString[1];
										C=tempString[2];
										D=tempString[3];
										if(!A.equals("被锁定")) {
											File delete_1=new File(A+" "+B+".txt");
											delete_1.delete();
											File delete_2=new File(A+" "+C+".txt");
											delete_2.delete();
											File delete_3=new File(A+" "+D+".txt");
											delete_3.delete();
											try {
												fw=new FileWriter("unlock.txt");
											} catch (IOException e1) {
												e1.printStackTrace();
											}
											try {
												fw.write("被锁定 用户账号\t时 间\r\n");
											} catch (IOException e1) {
												e1.printStackTrace();
											}
											try {
												fw.flush();
											} catch (IOException e1) {
												e1.printStackTrace();
											}
											try {
												fw.close();
											} catch (IOException e1) {
												e1.printStackTrace();
											}
											diag_userAccountUnlock.dispose();
											ta_userAccountUnlock.setText("");
											diag_message.setLocationRelativeTo(null);
											diag_message.setVisible(true);
											lb_message.setText("请注意:解锁成功!");
											lb_message.setFont(new Font("楷体",Font.BOLD,20));
										}
									}
								} catch (IOException e1) {
									e1.printStackTrace();
								}
							}
						}
					});
					diag_userAccountUnlock.add(bt_return_userAccountUnlock);
					bt_return_userAccountUnlock.setBounds(650, 520, 100, 28);
					bt_return_userAccountUnlock.setFont(new Font("黑体",Font.BOLD,15));
					bt_return_userAccountUnlock.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_return_userAccountUnlock) {
								diag_userAccountUnlock.dispose();
								ta_userAccountUnlock.setText("");
							}
						}
					});
					diag_userAccountUnlock.setLocationRelativeTo(null);
					diag_userAccountUnlock.setVisible(true);
				}
			}
		});
		//退出界面
		container.add(bt_signOut);
		bt_signOut.setBounds(300, 500, 200, 50);
		bt_signOut.setFont(new Font("黑体",Font.BOLD,20));
		bt_signOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JButton bt=(JButton)e.getSource();
				if(bt==bt_signOut) {
					diag_signOut.setTitle("退出");
					diag_signOut.setSize(400, 300);
					diag_signOut.setLayout(new FlowLayout(FlowLayout.CENTER,50,100));
					diag_signOut.add(bt_close);
					bt_close.setFont(new Font("黑体",Font.BOLD,15));
					bt_close.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_close) {
								System.exit(0);
							}
						}
					});
					diag_signOut.add(bt_cancel);
					bt_cancel.setFont(new Font("黑体",Font.BOLD,15));
					bt_cancel.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							JButton bt=(JButton)e.getSource();
							if(bt==bt_cancel) {
								diag_signOut.dispose();
							}
						}
					});
					diag_signOut.setLocationRelativeTo(null);
					diag_signOut.setVisible(true);
				}
			}
		});
		//管理员界面
		mainJFrame_4.setVisible(true);
	}
}

UserTest.java

//文件名:UserTest.java
package ATM;
import java.io.*;
import java.util.*;
public class UserTest {
	static ArrayList<UserAccount> userArrayList;//集合类-ArrayList类
	static UserAccount currentUserAccount;//当前用户账号
	static UserAccount currentUserAccount_1;//当前被转帐用户账号
	static File userFile;//File类
	static File currentUserFile;//当前用户文件
	static FileReader fr;//FileReader类
	static FileWriter fw;//FileWriter类
	public static void main(String[] args) throws Exception {
		userArrayList=new ArrayList<UserAccount>();//集合类-ArrayList类
		currentUserAccount=new UserAccount(null,null,0);//当前用户账号
		currentUserAccount_1=new UserAccount(null,null,0);//当前被转帐用户账号
		userFile=new File("userFile.txt");//File类
		if(!userFile.exists()) {
			userFile.createNewFile();
			fw=new FileWriter("userFile.txt");
			fw.write("6214837525982959 123456 100000.00\r\n");
			fw.write("6222032008007668 123456 100000.00\r\n");
			fw.write("6217003170032409 123456 100000.00\r\n");
			fw.write("6212252008001091 123456 100000.00\r\n");
			/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
			fw.flush();
			fw.close();
		}
		userArrayListRead();
		userArrayListWrite();
	}
	public static void userArrayListRead() throws Exception {
		fr=new FileReader("userFile.txt");//fr01
		BufferedReader br=new BufferedReader(fr);//字符流//br01
		String temp="";//03
		String[] tempString=new String[5];//04
		while((temp=br.readLine())!=null) {//05
			tempString=temp.split("\\s+");//split//06
			UserAccount ua=new UserAccount(tempString[0],tempString[1],Float.parseFloat(tempString[2]));//UserAccount//07
			userArrayList.add(ua);//ArrayList//08
		}
		br.close();//br02
		fr.close();//fr02
	}
	public static void userArrayListWrite() throws Exception {
		fw=new FileWriter("userFile.txt");//fw01
		StringBuilder sb=new StringBuilder();//02
		for(int i=0;i<userArrayList.size();i++) {//03
			sb.append(userArrayList.get(i).userAccount+" "+userArrayList.get(i).password+" "+userArrayList.get(i).balance+"\r\n");//append//04
		}
		fw.write(sb.toString());//05
		fw.flush();//06
		fw.close();//fw02
	}
}

AdministratorTest.java

//文件名:AdministratorTest.java
package ATM;
import java.io.*;
import java.util.*;
public class AdministratorTest {
	static ArrayList<AdministratorAccount> administratorArrayList;//集合类-ArrayList类
	static AdministratorAccount currentAdministratorAccount;//当前管理员账号
	static File administratorFile;//File类
	static File currentAdministratorFile;//当前管理员文件
	static FileReader fr;//FileReader类
	static FileWriter fw;//FileWriter类
	public static void main(String[] args) throws Exception {
		administratorArrayList=new ArrayList<AdministratorAccount>();//集合类-ArrayList类
		currentAdministratorAccount=new AdministratorAccount(null,null,0);//当前管理员账号
		administratorFile=new File("administratorFile.txt");//File类
		if(!administratorFile.exists()) {
			administratorFile.createNewFile();
			fw=new FileWriter("administratorFile.txt");
			fw.write("000000 000000 400000.00\r\n");
			/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
			fw.flush();
			fw.close();
		}
		administratorArrayListRead();
	}
	public static void administratorArrayListRead() throws Exception {
		fr=new FileReader("administratorFile.txt");//fr01
		BufferedReader br=new BufferedReader(fr);//字符流//br01
		String temp="";//03
		String[] tempString=new String[5];//04
		while((temp=br.readLine())!=null) {//05
			tempString=temp.split("\\s+");//split//06
			AdministratorAccount aa=new AdministratorAccount(tempString[0],tempString[1],Float.parseFloat(tempString[2]));
			administratorArrayList.add(aa);
		}
		br.close();//br02
		fr.close();//fr02
	}
}

UserAccount.java

//文件名:UserAccount.java
package ATM;
public class UserAccount {
	String userAccount;
	String password;
	float balance;
	/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
	public UserAccount(String userAccount,String password,float balance) {
		this.userAccount=userAccount;
		this.password=password;
		this.balance=balance;
	}
}

AdministratorAccount.java

//文件名:AdministratorAccount.java
package ATM;
public class AdministratorAccount {
	String administratorAccount;
	String password;
	float balance;
	/*
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056*/
	public AdministratorAccount(String administratorAccount,String password,float balance) {
		this.administratorAccount=administratorAccount;
		this.password=password;
		this.balance=balance;
	}
}

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://xxxxychen.blog.csdn.net/article/details/107825056

  • 36
    点赞
  • 191
    收藏
    觉得还不错? 一键收藏
  • 13
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值