-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrentAccount.java
More file actions
34 lines (27 loc) · 1.02 KB
/
Copy pathCurrentAccount.java
File metadata and controls
34 lines (27 loc) · 1.02 KB
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
package model.entity;
import exceptions.InvalidIFSCException;
import exceptions.MinimumBalanceException;
import model.enums.AccountType;
public class CurrentAccount extends Account {
// 1. Fields (private, final where appropriate)
private final String compName;
// 2. Constructor
public CurrentAccount(int accNo, String ifscCode, double balance, AccountType accType, String compName) throws InvalidIFSCException,MinimumBalanceException{
super(accNo, ifscCode, balance, accType);
this.compName = compName != null ? compName.trim() : "Unknown Company";
}
// 3. Business Getters
public String getCompName() {
return compName;
}
// 4. Interest Calculation (Current accounts = 0% interest)
@Override
public double calculateInterest() {
return 0.0; // Current accounts don't earn interest
}
// 5. toString() - Professional format
@Override
public String toString() {
return super.toString() + ", Company=" + compName;
}
}