-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriverBankAccount.java
More file actions
30 lines (25 loc) · 848 Bytes
/
Copy pathDriverBankAccount.java
File metadata and controls
30 lines (25 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class DriverBankAccount{
public static void main(String[]args){
BankAccount b1 = new BankAccount(1000001, "abc123");
BankAccount b2 = new BankAccount(1000231, "abcasdg23");
System.out.println("Account b1:");
b1.deposit(3000.0);
b2.deposit(1234.0);
System.out.println(b1);
System.out.println("Account b2:");
System.out.println(b2);
System.out.println();
double cashAmount = 300.0;
while(cashAmount < 3000) {
System.out.println("Attempt to move $"+cashAmount+" from the b1 to b2 account:");
if(b1.transferTo(b2, cashAmount, "abc123")) {
System.out.println(b1);
System.out.println(b2);
System.out.println();
} else {
System.out.println("Transfer Failed");
}
cashAmount *= 2;
}
}
}