forked from akash-coded/core-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUPIPaymentApps.java
More file actions
48 lines (40 loc) · 1.33 KB
/
UPIPaymentApps.java
File metadata and controls
48 lines (40 loc) · 1.33 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class UPIPaymentApps implements Cloneable {
String name;
String country;
int dailyLimit;
double maxDailyAmount;
// Address headOfficeLocation;
public UPIPaymentApps() {
}
public UPIPaymentApps(String name, String country, int dailyLimit, double maxDailyAmount) {
this.name = name;
this.country = country;
this.dailyLimit = dailyLimit;
this.maxDailyAmount = maxDailyAmount;
}
@Override
protected Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
@Override
public String toString() {
return "UPIPaymentApps [country=" + country + ", dailyLimit=" + dailyLimit + ", maxDailyAmount="
+ maxDailyAmount + ", name=" + name + "]";
}
}
class UPIDriver {
public static void main(String[] args) throws Exception {
UPIPaymentApps bhim = new UPIPaymentApps("BHIM", "India", 10, 100000);
System.out.println(bhim);
// not a copy, but an impostor
UPIPaymentApps phonePe = bhim;
phonePe.name = "PhonePe";
// shallow copy
UPIPaymentApps gPay = (UPIPaymentApps) bhim.clone();
gPay.name = "GPay";
System.out.println(phonePe);
System.out.println(gPay);
System.out.println(bhim);
}
}