-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD4-2.txt
71 lines (65 loc) · 2.1 KB
/
D4-2.txt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
interface IBank {
int CAUTION_MONEY = 2000;
String createAccount(Customer customer);
double issueVehicleLoan(String vehicleType, Customer customer);
double issueHouseLoan(Customer customer);
double issueGoldLoan(Customer customer);
}
class Customer {
private String name;
private String customerId;
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId= customerId;
}
}
class MumbaiBranch implements IBank {
public String createAccount(Customer customer){
return "Acc12345";
}
public double issueVehicleLoan(String vehicleType,Customer customer){
if(vehicleType.equals("bike")) {
return 100000;
}
else {
return 500000;
}
}
public double issueHouseLoan(Customer customer){
return 200000;
}
public double issueGoldLoan(Customer customer){
return 500000;
}
}
class Execute{
public static void main(String[] args){
IBank bank=new MumbaiBranch();
Customer customer = new Customer();
customer.setCustomerId("cust1001");
customer.setName("Ajay");
String accountNumber = bank.createAccount(customer);
System.out.println("Account number is..." +accountNumber);
double gloan = bank.issueGoldLoan(customer);
System.out.println("Gold loan amount is..." +gloan);
double hloan = bank.issueHouseLoan(customer);
System.out.println("House loan amount is..." +hloan);
double vloan = bank.issueVehicleLoan("bike", customer);
System.out.println("Vehicle loan amount is..." +vloan);
System.out.println("Caution money is..." +IBank.CAUTION_MONEY);
}
}
Output:
Account number is...Acc12345
Gold loan amount is...500000.0
House loan amount is...200000.0
Vehicle loan amount is...100000.0
Caution money is...2000