• 开学测试之——ATM


    ---恢复内容开始---

    package ATM;
     
    //信1705-2 20173568 李泽宇
     
    import java.util.*;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
     
    import java.io.IOException;
     
    public class Account {
     
     public static List<Account> accountlist=new LinkedList<Account>();
     private String accountID;
     private String accountname;
     private String operatedate;
     private int operatetype;
     private String accountpassword;
     private int accountbalance;
     private int amount;
    public Account() {};
    public  Account(String accountID,String accountname,String operatedate,int operatetype,String accountpassword,int accountbalance) {
        this.accountID=accountID;
        this.accountname=accountname;
        this.operatedate=operatedate;
        this.operatetype=operatetype;
        this.accountpassword=accountpassword;
        this.accountbalance=accountbalance;
    }
    public Account(String accountID,String accountname,String accountpassword,int accountbalance) {
        this.accountID=accountID;
        this.accountname=accountname;
        this.accountpassword=accountpassword;
        this.accountbalance=accountbalance;
    }
    public Account(String accountID,String accountname,String operatedate,int operatetype,int amount) {
        this.accountID=accountID;
        this.accountname=accountname;
        this.operatedate=operatedate;
        this.operatetype=operatetype;
        this.amount=amount;
    }
    public  String get_accountID() {
        return accountID;
    }
    public String get_accountname() {
        return accountname;
    }
    public String get_operatedate() {
        return operatedate;
    }
    public int get_operatetype() {
        return operatetype;
    }
    public String get_accountpassword() {
        return accountpassword;
    }
    public int get_accountbalance() {
        return accountbalance;
    }
    public int get_amount() {
        return amount;
    }
    public void set_accountID(String accountID) {
        this.accountID=accountID;
    }
    public void set_accountname(String accountname) {
        this.accountname=accountname;
    }
    public void set_operatedate(String operatedate) {
        this.operatedate=operatedate;
    }
    public void set_operatetype(int type) {
        this.operatetype=type;
    }
    public void set_accountpassword(String password) {
        this.accountpassword=password;
    }
    public void set_accountbalance(int balance) {
        this.accountbalance=balance;
    }
    public void set_amount(int amount) {
        this.amount=amount;
    }
    public  static void  addaccount (String accountID,String accountname,String accountpassword,int accountbalance) {
         accountlist.add(new Account(accountID,accountname,accountpassword,accountbalance));
    }
    public static void file_in() {
    File file0 = new File("F:/eclipse/ATM", "accountinformation.txt");
    addaccount("20173450","zhangqiang","000001",900);//创建第一个账户并放入list中
    addaccount("20173451","zhanghao","000002",1000);//创建第二个账户
    addaccount("20173452","sunyang","000003",700);//创建第三个账户
    addaccount("20173453","lihao","000004",1200);//创建第四个账户
    addaccount("20173454","liulei","000005",8500);//创建第五个账户//创建文件对象
    try {
        if (!file0.exists()) {               //如果文件不存在则新建文件
            file0.createNewFile();          
     
        }
        FileOutputStream output = new FileOutputStream(file0);
        for(int j=0;j<accountlist.size();j++) {
            byte[] bytes0 =accountlist.get(j).accountID.getBytes();
            byte[] bytes1 =accountlist.get(j).accountname.getBytes();
            byte[] bytes2 =accountlist.get(j).accountpassword.getBytes();
        output.write(bytes0);
        output.write(bytes1);
        output.write(bytes2);
        output.write(accountlist.get(j).accountbalance);
        }
        output.close();
                }catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
    在一个类中建成的文件,先把之前做的扒了过来,后面会在寒假完善

    ---恢复内容结束---

  • 相关阅读:
    Spring 学习——Spring IOC概念
    Oracle使用——Oracle表空间处理
    Spring 学习——Spring框架结构、概念
    Java错误——The hierarchy of the type is inconsistent错误
    Git教程
    git 常用操作
    "use strict"; 的正确使用
    react学习笔记(二)React表单详解
    chrome 添加有用扩展程序
    react学习笔记(一)
  • 原文地址:https://www.cnblogs.com/mitang0-0/p/10304603.html
Copyright © 2020-2023  润新知