张迪的课程设计报告(6)

2020-03-26 20:05

* scanner.next(); */

System.out.println(\ to = scanner.nextLong();

System.out.println(\ money = scanner.nextDouble(); boolean flg = false;

for (Account a : setAcc) { if (from.equals(a.getId()) && passwordFrom.equals(a.getPassword())) { if (a.withdraw(money) != null) { for (Account b : setAcc) {

if (to.equals(b.getId())) { b.deposit(money);

String str = setAcc.toString(); File file = creatFile(); writeFile(file, str);

System.out.println(\交易成功\ flg = true; break; } } } } }

if (flg == false) {

System.out.println(\交易失败\ }

choose(from, passwordFrom); return false; }

// 贷款

public Account requestLoan(Long id, double money) { String str = null;

Scanner scanner = new Scanner(System.in); System.out.println(\ money = scanner.nextDouble(); boolean flg = false;

for (Account a : setAcc) { if (id.equals(a.getId())

&& (a instanceof LoanSavingAccount LoanCreditAccount)) {

a.setLoanAmount((long) money); str = setAcc.toString();

a instanceof || File file = creatFile(); writeFile(file, str);

System.out.println(\交易成功\ str = a.getPassword(); flg = true; break; } }

if (flg == false) {

System.out.println(\交易失败\ }

choose(id, str); return null; }

// 还贷款

public Account payLoan(Long id, double money) { String str = null;

Scanner scanner = new Scanner(System.in); System.out.println(\ money = scanner.nextDouble(); boolean flg = false;

for (Account a : setAcc) { if (id.equals(a.getId())

&& (a instanceof LoanSavingAccount || a instanceof LoanCreditAccount)) {

if (a.withdraw(money) != null) {

a.setLoanAmount(a.getLoanAmount() - (long) money); str = setAcc.toString(); File file = creatFile(); writeFile(file, str);

System.out.println(\交易成功\ str = a.getPassword(); flg = true; break; } } }

if (flg == false) {

System.out.println(\交易失败\ }

choose(id, str); return null; }

// 设置透支额度

private Account updateCeiling(Long id, String password, double money) { Scanner scanner = new Scanner(System.in); System.out.println(\ money = scanner.nextDouble(); boolean flg = false;

for (Account a : setAcc) {

if ((a instanceof CreditAccount || a instanceof LoanCreditAccount && id.equals(a.getId()))

&& password.equals(a.getPassword())) { ((CreditAccount) a).setCeiling(money); String str = setAcc.toString(); File file = creatFile(); writeFile(file, str); flg = true; break; } }

if (flg == false) {

System.out.println(\设置失败\ } else {

System.out.println(\设置成功\ }

choose(id, password); return null; }

// 统计银行所有账户余额总数 public double amount() { double amount = 0;

for (Account a : setAcc) { amount += a.getBalance(); }

return amount; }

// 统计所有信用账户透支额度总数 public double sum() { double sum = 0;

for (Account a : setAcc) {

if (a instanceof CreditAccount || a instanceof LoanCreditAccount) { sum += ((CreditAccount) a).getCeiling(); } }

return sum; }

// 统计所有账户贷款的总额 public double totoal() { double sum = 0;

for (Account a : setAcc) { sum += a.getLoanAmount(); }

return sum; }

// 打印所有用户的总资产排名 public void totalAssets() {

Account[] a = setAcc.toArray(new Account[setAcc.size()]);

for (int i = 0; i < a.length; i++) { double sum = 0;

for (int j = 0; j < a.length; j++) {

if (a[i].getPersonId().equals(a[j].getPersonId())) { if (j < i) {

a[i].setId(0l); ;

break; } else {

sum += a[j].getBalance(); a[i].setBalance(sum); } } } }

for (int i = 0; i < a.length; i++) { Account acc;

for (int j = i + 1; j < a.length; j++) {

if (a[i].getBalance() < a[j].getBalance()) { acc = a[i]; a[i] = a[j]; a[j] = acc; } } }

for (int i = 0; i < a.length; i++) { if (a[i].getId() != 0) {

System.out.println(a[i]);

} } } }

4.3 接口

package ATM_Bank;

public interface Loanable { //贷款

public abstract Account requestLoan(double money); //还贷

public abstract Account payLoan(double money); }

4.4 测试类

package ATM_Bank;

public class Test {

public static void main(String[] args) { String str = \ System.out.println(str.length()); Bank bank = new Bank();

bank.register(null, null, null, null, null, null, 0); bank.amount(); } }

4.5 运行结果


张迪的课程设计报告(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:11010上巷过老巷措施

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: