Untitled
unknown
plain_text
2 years ago
864 B
18
Indexable
#Aggregation
class Customer:
#constructor
def __init__(self,name,gender,address):
self.name = name
self.gender = gender
self.address = address
def edit_profile(self,new_name,new_city,new_pincode,new_state):
self.name = new_name
self.address.change_address(new_city,new_pincode,new_state)
class Address:
#constructor
def __init__(self,city,pincode,state):
self.city = city
self.pincode = pincode
self.state = state
def change_address(self,new_city,new_pincode,new_state):
self.city = new_city
self.pincode = new_pincode
self.state = new_state
add = Address("Pune",456789,"MAHARASHTRA")
customer_one = Customer("Shantanu","M",add)
print(customer_one.address.pincode)
customer_one.edit_profile("divyesh","Mumbai",111111,"Maharashtra")
print(customer_one.address.pincode)Editor is loading...
Leave a Comment