Programming Exercise 3-1
Programming Exercise 10-3
# info.py
class Information:
def __init__(self, name, address, age, phone_number):
self.__name = name
self.__address = address
self.__age = age
self.__phone_number = phone_number
def set_name(self, name):
self.__name = name
def set_address(self, address):
self.__address = address
def set_age(self, age):
self.__age = age
def set_phone_number(self, phone_number):
self.__phone_number = phone_number
def get_name(self):
return self.__name
def get_address(self):
return self.__address
def get_age(self):
return self.__age
def get_phone_number(self):
return self.__phone_number
# Exercise 10-3.py
import info
def main():
# Create three instances of Information
my_info = info.Information(‘John Doe’,’111 My Street’, \
22, ‘555-555-1281’)
mom_info = info.Information(‘Mom’, ‘222 Any Street’, \
52, ‘555-555-1234’)
sister_info = info.Information(‘Jane Doe’, ‘333 Her Street’, \
20, ‘555-555-4444’)
print(‘My information:’)
display_info(my_info)
print()
print(“Mom’s information:”)
display_info(mom_info)
print()
print (“Sis’s infomation:”)
display_info(sister_info)
def display_info(info):
print(‘Name: ‘, info.get_name())
print(‘Address: ‘, info.get_address())
print(‘Age: ‘, info.get_age())
print(‘Phone Number: ‘, info.get_phone_number())
# Call the main function.
main()