每日日报2020 9/23

今天将昨天的那道题目写完吧。

package ATM系统;

import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

class Account{
private String accountID;
private String accountname;
private String operatedate;
private int operatetype;
private String accountpassword;
private int accountbalance;
private int amount;
public void setID (String x) {
accountID=x;
}
public void setname(String x) {
accountname=x;
}
public void setdate(String x){
operatedate = x;
}
public void settype(int x){
operatetype = x;
}
public void setword(String x){
accountpassword = x;
}
public void setbalance(int x){
accountbalance = x;
}
public void setamount(int x){
amount=x;
}
public void Set(String id,String name,String date,int type,String password,int balance,int amount_s){
setID(id);
setname(name);
setdate(date);
settype(type);
setword(password);
setbalance(balance);
setamount(amount_s);
}
public String GetaccountID(){
return accountID;
}
public String Getaccountname(){
return accountname;
}
public String Getoperatedate(){
return operatedate;
}
public int Getoperatetype(){
return operatetype;
}
public String Getaccountpassword(){
return accountpassword;
}
public int Getaccountbalance(){
return accountbalance;
}
public int Getamount(){
return amount;
}
public void Reset(){
amount =0;
accountbalance =0;
accountpassword ="nihao";
operatetype=0;
operatedate = "2020-09-10";
accountname = "songzhenxing";
accountID = "20194062";
}
public boolean RightId(){
return true;
}
public Account(){
amount =0;
accountbalance =0;
accountpassword ="nihao";
operatetype=0;
operatedate = "2020-09-10";
accountname = "songzhenxing";
accountID = "20194062";
}

}
public class AccountManager {

private Account ku[] = new Account[5];
private String List = "files/accountlist.txt";
private String Infor = "files/accountinformation.txt";
private String Today = "2020-9-20";
public void FirstWin() throws IOException{
System.out.println("***************************************************************");
System.out.println(" 欢迎使用中国工商银行自动柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 请输入你的账号: ");
System.out.println(" ");
System.out.println("***************************************************************");
Scanner sc=new Scanner(System.in);
String x = sc.next();
int existfor = 5;
for(int i=0;i<5;i++)
if(ku[i].GetaccountID().compareTo(x)==0)
{
existfor = i;
break;
}
if(existfor==5)
{
System.out.println(" 该卡不是工行卡!");
FirstWin();
}
else
SecondWin(existfor);
}
public void SecondWin(int pass) throws IOException{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+ku[pass].Getaccountname()+"账户使用中国工商银行自动柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 请输入你的密码: ");
System.out.println(" ");
System.out.println("***************************************************************");
int times = 0;
Scanner sc = new Scanner (System.in);
while(times<3) {
String saving = sc.nextLine();
if(ku[pass].Getaccountpassword().compareTo(saving)!=0)
System.out.println("密码录入错误");
else
break;
times++;
}
if(times==3)
FirstWin();
else
MainWin(pass);
}
void MainWin(int pass) throws IOException{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+ku[pass].Getaccountname()+"使用中国工商银行自助柜员系统 ");
System.out.println("***************************************************************");
System.out.println(" 1.存款 ");
System.out.println(" 2.取款 ");
System.out.println(" 3.转账汇款 ");
System.out.println(" 4.修改密码 ");
System.out.println(" 5.查询余额 ");
System.out.println("****************************************************************");
Scanner sc = new Scanner (System.in);
int temp = sc.nextInt();
}
public void fun1(int pass) throws IOException{
System.out.println("***************************************************************");
System.out.println(" 欢迎"+ku[pass].Getaccountname()+"使用中国工商银行自助柜员系统");
System.out.println("****************************************************************");
System.out.println(" 请输入金额 : ");
System.out.println(" ");
System.out.println("****************************************************************");
Scanner sc = new Scanner (System.in);
if(sc.hasNext("q"))
FirstWin();
else {
int JinE=sc.nextInt();
if(JinE<=0)
{
System.out.println("输出金额有误");
fun1(pass);
}
else
{
ku[pass].setamount(ku[pass].Getamount()+JinE);
ku[pass].setbalance(ku[pass].Getaccountbalance()+JinE);

System.out.println("***************************************************************");
System.out.println(" 欢迎"+ku[pass].Getaccountname()+"使用中国工商银行自助柜员系统");
System.out.println("****************************************************************");
System.out.println(" 当前账户存款操作成功。");
System.out.println(" 当前账户余额为:"+ku[pass].Getaccountbalance()+"元");
Scanner scs = new Scanner (new FileReader(List));
PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
{
pws.println(scs.nextLine());
}
pws.println(scs.nextLine());
pws.close();
Scanner scp = new Scanner (new FileReader("files/LinShi"));
PrintWriter pw = new PrintWriter (new FileWriter(List));
pw.print(ku[pass].GetaccountID());
pw.print(" ");
pw.print(Today);
ku[pass].setdate(Today);
pw.print(" ");
pw.print("SaveMoney");
pw.println(JinE);
while(!scp.hasNext("ENDOFTHISFILE"))
{
pw.println(scp.nextLine());
}
pw.println(scp.nextLine());
pw.close();
// writefile();
}
MainWin(pass);
}
}
public static void main(String[] args) throws IOException {
AccountManager ap = new AccountManager();
ap.FirstWin();
}

}

啊啊啊,不想写了,困了,没写完,溜了溜了。

posted @ 2020-09-23 23:56  宋振兴  阅读(43)  评论(0编辑  收藏  举报