-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckingAccount.java
54 lines (49 loc) · 1.07 KB
/
CheckingAccount.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
public class CheckingAccount extends BankAccount
{
private int transactionCount;
public CheckingAccount(String id)
{
id = this.getId();
}
public void deposit(double amount)
{
super.deposit(amount);
transactionCount++;
}
public void withdraw(double amount)
{
super.withdraw(amount);
transactionCount++;
}
public void deductFees()
{
if(transactionCount > 3)
{
double fees = (transactionCount - 3) * 2;
super.withdraw(fees);
}
transactionCount = 0;
}
public void print()
{
System.out.println("卡号:" + getId() + ";余额:"
+ super.getBalance() + ";交易次数:" + transactionCount);
}
/*public static void main(String[] args)
{
CheckingAccount ca = new CheckingAccount("C001");
ca.deposit(10000);
ca.deposit(10000);
ca.deposit(10000);
ca.withdraw(10000);
ca.withdraw(10000);
ca.deductFees();
ca.deposit(10000);
ca.deposit(10000);
ca.deposit(10000);
ca.withdraw(10000);
ca.withdraw(10000);
ca.deductFees();
System.out.println("卡号为" + ca.getId() + "的存款余额为" + ca.getBalance());
}*/
}