Narrowing Our Search…

seo3

Today we are going to implement two more AddressBook methods, printCertainAlpha() (thanks Jordan) and deleteContact().  Here’s a brief reminder of our discussion from class:

printCertainAlpha()

This function is similar to printContactList(), but it receives one letter and then only prints contacts whose last name begins with that letter.

deleteContact()

This function simply receives the index of the contact to delete and removes it.

Use this main program to test your code.

# *****************************************************
# Main Program
# *****************************************************

# Create a contact
mycontact = Contact("George","Washington", "Geo", "555-1234", "234-1600",
	"gwashington@usa.gov", "PutPhotoHere", "1600 Pennsylvania Ave NW", "Washington",
	"D.C.", "20500")

print "The first President was " + str(mycontact.firstname) + " " + str(mycontact.lastname) + "."
print "His email is " + str(mycontact.email) + "."

# Blank line
print ""

# Create an AddressBook object
myAddressBook = AddressBook('MyAddressBook')

# Add mycontact to AddressBook
myAddressBook.addContact(mycontact)

# Load Contacts from CSV file
myAddressBook.importFromCSVFile('us-500-2.csv')

print ""

# Sort by last name
myAddressBook.bubbleSort()

# Print address list - not this time
#myAddressBook.printContactList()

# Print just the M's
myAddressBook.printCertainAlpha("M")

# Remove #281
myAddressBook.deleteContact(281)

# Print just the M's again
myAddressBook.printCertainAlpha("M")


When you’ve finished, please submit your program using this submission link.