package bank; public class bankchaxun { public void chaxun(User[] cus){ bankdenglu a=new bankdenglu(); int zhanghao=a.denglu(cus); if(0!=zhanghao){ System.out.println("姓名:"+cus[zhanghao].getname()); System.out.println("账号:"+cus[zhanghao].getcard()); System.out.println("密码:"+cus[zhanghao].getmima()); System.out.println("余额:"+cus[zhanghao].getyue()); } } } ************************************************** package bank; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Scanner; public class bankcunkuan{ Scanner in = new Scanner(System.in); public void cunkuan(User[] cus){ bankdenglu a=new bankdenglu(); int zhanghao=a.denglu(cus); if(0!=zhanghao){ System.out.println("输入存款金额:"); double money=in.nextDouble(); money+=cus[zhanghao].getyue(); cus[zhanghao].setyue(money); System.out.println("银行卡余额为:"+cus[zhanghao].getyue()); } } ************************************************** package bank; import java.util.Scanner; public class bankdenglu { Scanner in = new Scanner(System.in); public int denglu(User[] cus){ System.out.println("请输入账号"); int zhanghao=in.nextInt(); if(zhanghao<1000||zhanghao>=10000||""==(cus[zhanghao].getmima())){ System.out.println("输入账号不存在"); return 0; }else{ System.out.println("请输入密码"); String mima=in.next(); if((cus[zhanghao].getmima()).equals(mima)){ System.out.println("登录成功"); return zhanghao; } else{ System.out.println("密码错误"); return 0; } } } } ************************************************** package bank; import java.util.Scanner; public class bankmenu { Scanner in = new Scanner(System.in); public void menu(){ User[] cus =new User[10000]; cus[1000]=new User("tiantian",1000,"123456",123); bankcunkuan b=new bankcunkuan(); bankqukuan c=new bankqukuan(); bankchaxun d=new bankchaxun(); bankxiugai e=new bankxiugai(); System.out.println("\t银行管理系统"); System.out.println("***************************"); System.out.println("\t1.------存款"); System.out.println("\t2.------取款"); System.out.println("\t3.------查询"); System.out.println("\t4.------修改密码"); System.out.println("***************************"); System.out.println("请输入服务项目:"); while(true){ int key=in.nextInt(); switch(key){ case 1:b.cunkuan(cus);break; case 2:c.qukuan(cus);break; case 3:d.chaxun(cus);break; case 4:e.xiugai(cus);break; default:System.out.println("输入不正确,请重新输入"); } if(key>=1&&key<=4){ break; } } } } ************************************************* package bank; import java.util.Scanner; public class bankqukuan { Scanner in = new Scanner(System.in); public void qukuan(User[] cus){ bankdenglu a=new bankdenglu(); int zhanghao=a.denglu(cus); if(0!=zhanghao){ System.out.println("请输入取款金额"); double money=in.nextDouble(); if(money<=cus[zhanghao].getyue()){ double yue=cus[zhanghao].getyue(); yue-=money; cus[zhanghao].setyue(yue); System.out.println("取款成功"); System.out.println("银行卡余额为:"+cus[zhanghao].getyue()); System.exit(0); } else { System.out.println("余额不足"); } } } } ************************************************** package bank; import java.util.Scanner; public class bankxiugai { Scanner in = new Scanner(System.in); public void xiugai(User[] cus){ bankdenglu a=new bankdenglu(); int zhanghao=a.denglu(cus); if(0!=zhanghao){ System.out.println("请输入新密码"); String mima=in.nextLine(); cus[zhanghao].setmima(mima); System.out.println("修改完成"); } } } ************************************************** package bank; public class User { private String name = ""; private int card=1000; private String mima = ""; private double yue=0; public User(String name,int card,String mima,double yue){ this.name=name; this.card=card; this.mima=mima; this.yue=yue; } public void setname(String name){ this.name=name; } public void setcard(int card){ this.card=card; } public void setmima(String mima){ this.mima=mima; } public void setyue(double yue){ this.yue=yue; } public String getname(){ return name; } public int getcard(){ return card; } public String getmima(){ return mima; } public double getyue(){ return yue; } } ************************************************** package bankTest; import javax.swing.*; import java.awt.*; import java.awt.event.*; import bank.User; import bank.bankchaxun; import bank.bankcunkuan; import bank.bankmenu; import bank.bankqukuan; import bank.bankxiugai; public class test { public static void main(String[] args){ bankmenu d=new bankmenu(); d.menu(); Window win = new Window(); // win.setBounds(300, 200, 500, 500);//x,y,width,height设置窗口的位置及大小 win.setTitle("银行系统"); } }
时间: 2024-10-23 01:17:48