Id += index; return Id; }
public void choose(Long id, String str) { Scanner scanner = new Scanner(System.in); System.out
.println(\、存钱 2、取钱 3、转账 4、贷款 5、还款 6、设置透支额度\
int i = scanner.nextInt(); while (i > 6 || i < 1) {
System.out.println(\重新选择\ i = scanner.nextInt(); }
switch (i) { case 1:
deposit(id, 0); break; case 2:
withdraw(id, str, 0); break; case 3:
transfer(id, str, null, 0); break; case 4:
requestLoan(id, 0); break; case 5:
payLoan(id, 0); break; case 6:
updateCeiling(id, str, 0); break; } }
// 用户注册
public Account register(Long id, String password, String repassword, String name, String personID, String email, int type) { File file = creatFile(); boolean flg = false; // 项目需求规定账户类型:0 – 储蓄账户 1 – 信用账户 2 – 可贷款储蓄账户 3– 可贷款信用账户 id = getID();
System.out.println(id);
Scanner scanner = new Scanner(System.in); System.out.println(\ password = scanner.next();
System.out.println(\ repassword = scanner.next();
while (password.contentEquals(repassword) == false) { System.out.println(\确认密码错误\ repassword = scanner.next(); }
System.out.println(\ name = scanner.next();
System.out.println(\ personID = scanner.next();
System.out.println(\ email = scanner.next();
System.out.println(\选择帐号类型 :0 – 储蓄账户 1 – 信用账户 2 – 可贷款储蓄账户 3– 可贷款信用账户\ type = scanner.nextInt(); switch (type) { case 0:
setAcc.add(new SavingAccount(id, password, name, personID, email, 0.0));
String str = setAcc.toString(); writeFile(file, str); flg = true; break; case 1:
setAcc.add(new CreditAccount(id, password, name, personID, email, 0.0, 0.0));
str = setAcc.toString(); writeFile(file, str); flg = true; break; case 2:
setAcc.add(new LoanSavingAccount(id, password, name, personID, email, 0.0, 0l)); str = setAcc.toString(); writeFile(file, str); flg = true; break; case 3:
setAcc.add(new LoanCreditAccount(id, password, name, personID, email, 0.0, 0.0, 0l));
}
str = setAcc.toString(); writeFile(file, str); flg = true; break; }
if (flg == true) { index++;
System.out.println(\注册成功\} else {
System.out.println(\注册失败\}
System.out.println(\、用户注册 2、用户登录\int i = scanner.nextInt(); while (i != 1 && i != 2) {
System.out.println(\重新选择\ i = scanner.nextInt(); }
switch (i) { case 1:
register(null, null, null, null, null, null, 0); // 用户注册 break; case 2:
login(null, null); // 用户登录 break; }
return null;
// 用户登录
public Account login(Long id, String password) { Scanner scanner = new Scanner(System.in); System.out.println(\ id = scanner.nextLong();
System.out.println(\ password = scanner.next(); boolean flg = false;
for (Account a : setAcc) {
if (id.equals(a.getId()) && password.equals(a.getPassword())) { flg = true; break; } }
if (flg == true) {
System.out.println(\登录成功\
}
choose(id, password); } else {
System.out.println(\登录失败\
System.out.println(\、用户注册 2、用户登录\ int i = scanner.nextInt(); while (i != 1 && i != 2) {
System.out.println(\重新选择\ i = scanner.nextInt(); }
switch (i) { case 1:
register(null, null, null, null, null, null, 0); // 用户注册 break; case 2:
login(null, null); // 用户登录 break; } }
return null;
// 用户存款
private Account deposit(Long id, double money) { String str = null;
Scanner scanner = new Scanner(System.in);
// System.out.println(\System.out.println(\money = scanner.nextDouble(); boolean flg = false;
for (Account b : setAcc) {
if (id.equals(b.getId())) { b.deposit(money);
str = setAcc.toString(); File file = creatFile(); writeFile(file, str); str = b.getPassword(); flg = true; break; } }
if (flg == true) {
System.out.println(\交易成功\
}
} else {
System.out.println(\交易失败\}
choose(id, str); return null;
// 用户取款
private Account withdraw(Long id, String password, double money) { Scanner scanner = new Scanner(System.in); /*
* System.out.println(\
* System.out.println(\ */
System.out.println(\ money = scanner.nextDouble(); boolean flg = false;
for (Account a : setAcc) {
if (id.equals(a.getId()) && password.equals(a.getPassword())) { if (a.withdraw(money) != null) { String str = setAcc.toString(); File file = creatFile(); writeFile(file, str); flg = true; }
break; } }
if (flg == true) {
System.out.println(\交易成功\ } else {
System.out.println(\交易失败\ }
choose(id, password); return null; }
// 转账功能
private boolean transfer(Long from, String passwordFrom, Long to, double money) {
Scanner scanner = new Scanner(System.in); /*
* System.out.println(\ * System.out.println(\
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库张迪的课程设计报告(5)在线全文阅读。
相关推荐: