//信1705-3 20173507 周龙海
package account;
public class account {
private String accountID;
private String accountname;
private String operatedate;
private int operatetype;
private String accountpassword;
private int accountbalance;
private int amount;
account ()
{
accountID = "" ;
accountname = "" ;
operatedate = "" ;
operatetype = 0 ;
accountpassword = "" ;
accountbalance =0 ;
amount =0 ;
}
account (String a , String b , String c , int d , String e , int f , int g )
{
accountID = a ;
accountname = b ;
operatedate = c ;
operatetype = d ;
accountpassword = e ;
accountbalance = f ;
amount = g ;
}
//设置accountID的值
public void set_accountID(String str)
{
accountID = str;
}
//获取accountID的值
public String get_accountID()
{
return accountID;
}
//设置accountname的值
public void set_accountname(String str)
{
accountname = str;
}
//获取accountname的值
public String get_accountname()
{
return accountname;
}
//设置operatedate的值
public void set_operatedate(String str)
{
operatedate = str;
}
//获取operatedate的值
public String get_operatedate()
{
return operatedate;
}
//设置operatetype的值
public void set_operatetype(int i)
{
operatetype = i;
}
//获取operatetype的值
public int get_operatetype()
{
return operatetype;
}
//设置accountpassword的值
public void set_accountpassword(String str)
{
accountpassword = str;
}
//获取accountpassword的值
public String get_accountpassword()
{
return accountpassword;
}
//设置accountbalance的值
public void accountbalance(int i)
{
accountbalance = i;
}
//获取accountbalance的值
public int get_accountbalance()
{
return accountbalance;
}
//设置amount的值
public void set_amount(int i)
{
amount = i;
}
//获取amount的值
public int get_amount()
{
return amount;
}
}
//信1705-3 20173507 周龙海
package account;
import java.util.Scanner;
import java.io.*;
import account.account;
public class accountmanager {
private account ai[];
private int number;
//设置数组大小
Scanner scanner = new Scanner(System.in);
String ID;//输入的账号
int A = 0;// 判断对错,0为错
int T = 0;// 正确数
String password;// 密码
accountmanager()
{
number=0;
ai=new account[100];
}
//系统界面1
private static void face()
{
System.out.println("***************************************************");
System.out.println(" 欢迎使用中国工商银行自动柜员系统");
System.out.println("***************************************************");
System.out.println(" 请输入您的账号:");
System.out.println("***************************************************");
}
public static void main(String[] args) throws Exception {
while(true)
{
dang0.jiemiankaishi();
String Id=in.nextLine();
dang1.setAccountID(Id);
dang1.bianbie();
if(dang1.bianbie()==true)
{
dang1.bianbie2();
break;
}
count++;
if(count>2)
{
System.out.println("该账号三次录入错误,该卡已被系统没收,请与工行及时联系处理");
break;
}
}
while(true)
{
dang0.shumima();
String shupassword=in.nextLine();
if(dang1.bianbiemima1(shupassword)==true)
{
String password=dang1.getAccountpassword();
if((password.equals(shupassword)))
break;
}
System.out.println("密码输入错误,请重新输入");
count++;
if(count>2)
{
System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理");
break;
}
}
String xuanze1="1";
String xuanze2="2";
String xuanze3="3";
String xuanze4="4";
String xuanze5="5";
String xuanze6="q";
String xuanze;
while(true)
{
dang1.shuzijiemian();
xuanze=in.nextLine();
if((xuanze.equals(xuanze1)))
{
dang1.cunkuan();
int cunkuanshuzhi=in.nextInt();
if(cunkuanshuzhi%100!=0)
{
System.out.println("输入金额有误,返回操作界面");
}
else
{
dang1.cunkuanshezhi(cunkuanshuzhi);
dang1.cunkuanchengongjiemian();
}
}
else if((xuanze.equals(xuanze2)))
{
dang1.qukuanjiemian();
int qukuanxuanxiang=in.nextInt();
switch(qukuanxuanxiang)
{
case 1:
{
dang1.bianbieluru(100);
}break;
case 2:
{
dang1.bianbieluru(500);
}break;
case 3:
{
dang1.bianbieluru(1000);
}break;
case 4:
{
dang1.bianbieluru(1500);
}break;
case 5:
{
dang1.bianbieluru(2000);
}break;
case 6:
{
dang1.bianbieluru(5000);
}break;
case 7:
{
System.out.print("请输入其他金额:");
int luruyue=in.nextInt();
dang1.bianbieluru(luruyue);
}break;
case 8:
{
System.out.println("感谢使用!");
System.exit(0);
}break;
case 9:
{
break;
}
}
}
else if((xuanze.equals(xuanze3)))
{
dang1.zhuanzhangjiemian();
String zhuanzhangzhanghu=in.nextLine();
dang1.zhuanzhangzhanghupanding(zhuanzhangzhanghu);
dang2.bianbie();
if(dang2.bianbie()==true)
{
dang2.bianbie2();
dang1.zhuanzhangjinejiemian();
int zhuanzhangjine=in.nextInt();
if(dang1.zhuanzhangbianbie(zhuanzhangjine, zhuanzhangzhanghu)==true)
dang2.zhnaghu2zenyue(zhuanzhangjine);
}
}
else if((xuanze.equals(xuanze4)))
{
dang1.xiugaimimajiemian();
String shurumima=in.nextLine();
dang1.bianbiemima(shurumima);
dang1.mimacunruwenjian();
dang1.mimachongxinxieru();
}
else if((xuanze.equals(xuanze5)))
{
dang1.chaxungongneng();
}
else if((xuanze.equals(xuanze6)))
{
}
}
}
public boolean bianbie()throws IOException //辨别账户位数
{
if(accountID.length()!=8)
{
System.out.println("该卡不是工行卡");
return false;
}
else
return true;
}
public boolean bianbiemima1(String ps)throws IOException //辨别密码位数
{
if(ps.length()!=6)
{
System.out.println("密码格式错误");
return false;
}
else
return true;
}
public void bianbie2()throws Exception //辨别账户信息
{
String fileContent = readFileContent("D:/accountinformation.txt");
System.out.println(fileContent);
}
private static String readFileContent(String fileName) throws IOException {
File file = new File(fileName);
BufferedReader bf = new BufferedReader(new FileReader(file));
String content = "";
StringBuilder sb = new StringBuilder();
String Idjia1=atmbianliang.getAccountID();
while(content != null){
content = bf.readLine();
if((Idjia1.equals(content)))
{
System.out.println("账户正确");
String zhanghumima=bf.readLine();
accountpassword=zhanghumima;
}
if(content == null){
break;
}
}
bf.close();
System.out.println("识别账户结束");
return sb.toString();
}
public void bianbie001()throws Exception //辨别转账账户
{
String fileContent2 = readFileContent2("D:/accountinformation.txt");
System.out.println(fileContent2);
}
private static String readFileContent2(String fileName) throws IOException {
File file = new File(fileName);
BufferedReader bf = new BufferedReader(new FileReader(file));
String content = "";
StringBuilder sb = new StringBuilder();
String Idjia1=atmbianliang.getAccountID();
while(content != null){
content = bf.readLine();
if((Idjia1.equals(content)))
{
System.out.println("账户正确");
String zhanghumima=bf.readLine();
accountpassword=zhanghumima;
}
if(content == null){
break;
}
}
bf.close();
System.out.println("识别账户结束");
return sb.toString();
}
public void cunkuanshezhi(int a) throws FileNotFoundException
{
accountbalance=accountbalance+a;
cunkuanjilu(a);
}
public void zhuanzhangzhanghupanding(String c)
{
if((c.equals(accountID)))
{
System.out.println("账户不能是自己");
}
else
return;
}
public void bianbieluru(int b)throws FileNotFoundException
{
if(accountbalance>=b)
{
accountbalance=accountbalance-b;
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 当前账户取款"+b+"元操作成功 ");
System.out.println(" 当前账户余额为:"+accountbalance+"元 ");
System.out.println("***************************************************************");
qukuanjilu(b);
}
else
System.out.println("账户余额不足");
}
public void qukuanjilu(int a)throws FileNotFoundException //取款记录写入
{
String filePath = "D:/accountlist.txt";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
try
{
File file = new File(filePath);
PrintStream qk = new PrintStream(new FileOutputStream(file));
qk.append("操作日期"+df.format(new Date())+"取款 "+a+"元");
}catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
public boolean zhuanzhangbianbie(int a,String b)throws FileNotFoundException
{
if(accountbalance>=a)
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 请确认是否向"+b+"转账"+a+"元 (Y确认转账,N不转账) ");
String zhuanzhangqueren=in.nextLine();
if((zhuanzhangqueren.equals("Y")))
{
accountbalance=accountbalance-a;
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 当前账户向"+b+"成功转账"+a+"元");
System.out.println(" 当前账户余额为"+accountbalance+"元");
System.out.println("***************************************************************");
zhuanzhangjilu(a);
return true;
}
else
{
return false;
}
}
return false;
}
public void zhuanzhangjilu(int a)throws FileNotFoundException
{
String filePath = "D:/accountlist.txt";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
try
{
File file = new File(filePath);
PrintStream zz = new PrintStream(new FileOutputStream(file));
zz.append("操作日期"+df.format(new Date())+"转账 "+a+"元");
}catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
public void zhnaghu2zenyue(int zz2)
{
accountbalance=accountbalance+zz2;
}
public void bianbiedangqianmima()
{
String dangqianmima=in.nextLine();
if((dangqianmima.equals(accountpassword)))
return;
else
System.out.println("当前密码录入错误");
}
public void bianbiemima(String a)
{
if((a.equals(accountpassword)))
{
String xiugaimima=in.nextLine();
String querenmima=in.nextLine();
if((xiugaimima.equals(querenmima)))
{
accountpassword=querenmima;
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 当前账户密码修改成功 ");
System.out.println("***************************************************************");
}
else
{
System.out.println(" 修改密码与确认密码不一致 ");
return;
}
}
else
{
System.out.println(" 当前密码录入错误 ");
return;
}
}
public void xiugaimimaluru()throws FileNotFoundException
{
String filePath = "D:/accountlist.txt";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
try
{
File file = new File(filePath);
PrintStream xmm = new PrintStream(new FileOutputStream(file));
xmm.append("操作日期"+df.format(new Date())+" 修改密码");
}catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
public void mimacunruwenjian()throws Exception //将文件中的数据写出
{
String fileContent3 = readFileContent3("D:/accountinformation.txt");
System.out.println(fileContent3);
}
private static String readFileContent3(String fileName) throws IOException {
File file = new File(fileName);
BufferedReader bf = new BufferedReader(new FileReader(file));
StringBuilder sb = new StringBuilder();
int zzi=0;
while(zzi<6) {
content2[zzi] = bf.readLine();
zzi++;
}
bf.close();
return sb.toString();
}
public void mimachongxinxieru() throws FileNotFoundException //再将密码写入文件
{
int i=0;
String filePath = "D:/accountinformation.txt";
try
{
File file = new File(filePath);
PrintStream ps = new PrintStream(new FileOutputStream(file));
while(i<6)
{
ps.println(content2[i]);
if((content2[i].equals(accountID)))
ps.println(accountpassword);
i++;
}
}catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
public void cunkuanjilu(int a)throws FileNotFoundException //存款记录记录
{
String filePath = "D:/accountlist.txt";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
try
{
File file = new File(filePath);
PrintStream ck = new PrintStream(new FileOutputStream(file));
ck.append("操作日期"+df.format(new Date())+"存款 "+a+"元");
}catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
public void cunkuan() //存款界面
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 请输入存款金额; ");
System.out.println("***************************************************************");
}
public void shuzijiemian()
{
System.out.println("***************************************************************");
System.out.print(" 欢迎");
System.out.print(accountID);
System.out.println("使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 1.存款 ");
System.out.println(" 2.取款 ");
System.out.println(" 3.转账汇款 ");
System.out.println(" 4.修改密码 ");
System.out.println(" 5.查询余额 ");
System.out.println("***************************************************************");
}
public void cunkuanchengongjiemian()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 当前账户存款操作成功 ");
System.out.println(" 当前账户余额为:"+accountbalance+"元 ");
System.out.println("***************************************************************");
}
public void qukuanjiemian()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 当前账户每日可以支取2万元 ");
System.out.println(" 1、100元 ");
System.out.println(" 2、500元 ");
System.out.println(" 3、1000元 ");
System.out.println(" 4、1500元 ");
System.out.println(" 5、2000元 ");
System.out.println(" 6、5000元 ");
System.out.println(" 7、其他金额 ");
System.out.println(" 8、退卡 ");
System.out.println(" 9、返回 ");
System.out.println("***************************************************************");
}
public void zhuanzhangjiemian()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 请输入转账账户 ");
System.out.println("***************************************************************");
}
public void zhuanzhangjinejiemian()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 请输入转账金额 ");
System.out.println("***************************************************************");
}
public void xiugaimimajiemian()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 请输入当前密码: ");
System.out.println(" 请输入修改密码: ");
System.out.println(" 请输入确认密码: ");
System.out.println("***************************************************************");
}
public void chaxungongneng()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 当前账户余额为:"+accountbalance+"元 ");
System.out.println(" 账户清单信息为: ");
System.out.println("***************************************************************");
}
}
//信1705-3 20173507 周龙海
package account;
import java.util.Scanner;
public class main {
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
account app;
String str1,str2;
accountmanager m=new accountmanager();
face1();
str1 = input.next();
face2();
str2 = input.next();
yue();
}
private static void face1()
{
System.out.println("***************************************************");
System.out.println(" 欢迎使用中国工商银行自动柜员系统");
System.out.println("***************************************************");
System.out.println(" 请输入您的账号:");
System.out.println("***************************************************");
}
private static void face2()
{
System.out.println("***************************************************");
System.out.println(" 欢迎使用中国工商银行自动柜员系统");
System.out.println("***************************************************");
System.out.println(" 请输入您的密码:");
System.out.println("***************************************************");
}
public static void yue()
{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+accountID+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 当前账户存款操作成功。 ");
System.out.print(" 当前账户余额为:");
System.out.print(accountbalance);
System.out.print("元");
System.out.println("***************************************************************");
}
}