I created this class:
class Family:
def __init__(self):
self.__name = ""
self.__address = ""
self.__age = ""
self.__phone = ""
# Mutator Methods
def setName (self,mName):
self.__name = mName
def setAddress (self,mAddress):
self.__address = mAddress
def setAge (self,mAge):
self.__age = mAge
def setPhone (self,mPhone):
self.__phone = mPhone
# Accessor Methods
def getName():
return __name
def getAddress():
return __address
def getAge():
return __age
def getPhone():
return __phone
Using the main module, I created three instances of the family class and put them in a list.
def main():
objectOne = familyClass.Family()
objectTwo = familyClass.Family()
objectThree = familyClass.Family()
membersList = [objectOne,objectTwo,objectThree]
I, then, created a loop that asks the user to input the information for each object then another loop to print out the information:
for index in range(0,3):
membersList[index].setName = input("Enter the name: ")
membersList[index].setAddress = input("Enter the address: ")
membersList[index].setAge = input("Enter the age: ")
membersList[index].setPhone = input("Enter the phone: ")
print()
for index in range(0,3):
print("Here's the family members entered:")
print('Name: {}'.format(membersList[index].getName))
print('Address: {}'.format(membersList[index].getAddress))
print('Age: {}'.format(membersList[index].getAge))
print('Phone: {}'.format(membersList[index].getPhone))
print()
but I kept getting this:
Here's the family members entered:
Name: <bound method Family.getName of <familyClass.Family object at 0x106264970>>
Address: <bound method Family.getAddress of <familyClass.Family object at 0x106264970>>
Age: <bound method Family.getAge of <familyClass.Family object at 0x106264970>>
Phone: <bound method Family.getPhone of <familyClass.Family object at 0x106264970>>