开学测试之——ATM
2024-10-20 20:32:27
---恢复内容开始---
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;
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();
在一个类中建成的文件,先把之前做的扒了过来,后面会在寒假完善
---恢复内容结束---
最新文章
- Android Volley
- 《jQuery知识点总结》(二)
- Javascript自己动手实现getter/setter
- App Transport Security has blocked a cleartext
- Eclipse自动补全功能和自动生成作者、日期注释等功能设置
- android view生命周期
- 让浏览器进行跨域访问, 开发阶段需要跨域访问的测试方案 chrome的快捷方式里面 加 ";C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; --args --disable-web-security
- Linux系统备份与还原
- Android系统进程间通信Binder机制在应用程序框架层的Java接口源代码分析
- android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
- LVS-NAT搭建HTTP及HTTPS
- python logging一个通用的使用模板
- QT中的相对位置,绝对位置之间的转换(maptoglobal,mapfromglobal)
- 【12】Django 中间件
- PS制作简洁漂亮的立体抽丝文字
- Redis详解与常见问题解决方案
- 10元买啤酒问题Java解法
- BZOJ2512 : Groc
- Salesforce的报表和仪表板
- vue-底部导航栏