-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUPIApps.java
More file actions
93 lines (75 loc) · 2.71 KB
/
UPIApps.java
File metadata and controls
93 lines (75 loc) · 2.71 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
class Location {
String street;
String city;
public Location(String city) {
this.city = city;
}
public Location(String street, String city) {
this(city);
this.street = street;
}
@Override
public String toString() {
return "Street : " + street + ", City : " + city + "\n";
}
}
class Address {
Location location;
String state;
String country;
public Address(Location location, String state) {
this.location = location;
this.state = state;
}
public Address(Location location, String state, String country) {
this.location = location;
this.state = state;
this.country = country;
}
@Override
public String toString() {
return location + "State : " + state + ", Country : " + country + "\n";
}
}
class UPIPaymentApps implements Cloneable {
String name;
String country;
int dailyLimit;
double maxDailyAmount;
Address headOfficeLocation;
public UPIPaymentApps(String name, String country, int dailyLimit, double maxDailyAmount,
Address headOfficeLocation) {
this.name = name;
this.country = country;
this.dailyLimit = dailyLimit;
this.maxDailyAmount = maxDailyAmount;
this.headOfficeLocation = headOfficeLocation;
}
@Override
protected Object clone() throws CloneNotSupportedException {
Address address = new Address(this.headOfficeLocation.location, this.headOfficeLocation.state,
this.headOfficeLocation.country);
return new UPIPaymentApps(this.name, this.country, this.dailyLimit, this.maxDailyAmount, address);
}
@Override
public String toString() {
return "UPIPaymentApp :-\nName : " + name + "\ncountry :" + country + "\ndailyLimit : " + dailyLimit
+ "\nmaxDailyAmount : " + maxDailyAmount + "\nHead Office Location :-\n" + headOfficeLocation + "\n";
}
}
public class UPIApps {
public static void main(String[] args) throws Exception {
Location bhimLocation = new Location("Janakpuri", "Delhi");
Address bhimAddress = new Address(bhimLocation, "Delhi", "India ");
UPIPaymentApps bhim = new UPIPaymentApps("BHIM", "India", 10, 100000, bhimAddress);
System.out.println(bhim);
UPIPaymentApps paytm = (UPIPaymentApps) bhim.clone();
paytm.name = "PayTm";
Location paytmLocation = new Location("Sector 12", "Noida");
Address paytmAddress = new Address(paytmLocation, "Uttar Pardesh", "India");
paytm.headOfficeLocation = paytmAddress;
System.out.println(paytm);
System.out.println("Bhim Info After Changes:-");
System.out.println(bhim);
}
}