I'm starting to use classes to create a simple contacts output, and then an updated version like this:
My Contacts
-----------
??? Murphy 555-555-8980
George Smith 555-555-2323
Mike Johnson 555-555-4780
-----------
My Contacts
-----------
Cade Murphy 555-555-8980
President George Smith 555-555-2323
Professor Mike Johnson 555-555-4780
----------
I have the functions set up correctly, but I don't know what to put into class Contact
so that it prints what I want.
class Contact:
# I don't know what to put here
def print_directory(contacts):
print("My Contacts")
print("-----------")
for person in contacts:
print(person)
print("-----------\n")
def main():
champ = Contact("???", "Murphy", "555-555-8980")
president = Contact("George", "Smith", "555-555-2323")
professor = Contact("Mike", "Johnson", "555-555-4780")
contacts = [champ, president, professor]
print_directory(contacts)
champ.set_first_name("Cade")
president.set_title("President")
professor.set_title("Professor")
print_directory(contacts)
main()
I tried looking at tutorials and documentation on classes, but I'm not getting anywhere. Any help would be appreciated, Thank you.