开学测试之——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();
在一个类中建成的文件,先把之前做的扒了过来,后面会在寒假完善

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

转载于:https://www.cnblogs.com/mitang0-0/p/10304603.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值