"""
FriendInfo.py

Class definition for a list of contacts.
Instance variables: name, phone, email
Methods: constructor, newInfo, updateName, updatePhone,
          updateEmail, showInfo

CSC111 Class example April 12, 2011
J Cardell

"""
class FriendInfo:
    def __init__(self):
        """ This is the constructor for class FriendInfo
        You must name this method __init__ and have one
        parameter - self. This method is used to define
        the instance variables. NOTE that the instance
        variables is refered to via the notation "self."
        followed by the name of the variable."""
        self.name = None
        self.phone = None
        self.email = None

    def newInfo(self, nm, ph, em):
        """Enter complete information for this contact,
        including a value for each instance variable,
        name, phone and email."""
        self.name = nm
        self.phone = ph
        self.email = em

    def updateName (self, newNm):
        self.name = newNm
        
    def updatePhone (self, newPh):
        self.phone = newPh

    def updateEmail (self, newEm):
        self.email = newEm

    def getName (self):
        return self.name
        
    def getPhone (self):
        return self.phone

    def getEmail (self):
        return self.email

    def showInfo (self):
        # Note the "\" character, that indicates to the
        # Python interpreter that the given line of code
        # continues onto the next line. This is used to make
        # your file easier to read for people
        print "This friend's info is:\n\t%s\n\t%s\n\t%s" \
              % (self.name, self.phone, self.email)


#--------------------------------------
# Testing Area
#--------------------------------------
#
# The line following the 'if' keyword below indicates that
# the Python code inside the 'if' will only be executed
# when this file, Greeting.py, is executed directly. IF
# Greeting is imported into a second file, with the result
# that these class methods are called from that second file,
# then the code following the 'if' keyword below is NOT
# executed.

if __name__ == "__main__":

    print "\n\nCreating new information entries..."
    f1 = FriendInfo()
    f2 = FriendInfo()

    print "\nFilling in data"
    f1.newInfo('Abby', '1111', 'abby@smith.edu')
    f2.newInfo('Betty', '2222', 'betty@smith.edu')

    print "\nPrinting information in database"
    f1.showInfo()
    f2.showInfo()

    print "\nUpdating the information"
    f1.updatePhone('3333')
    f2.updateEmail('BettyBoop@smith.edu')

    print "\nShowing the updated info\n"
    f1.showInfo()
    f2.showInfo()
    
    print
    print "Using the getXX() methods..." 
    print "getName = ", f1.getName()
    print "getPhone = ", f1.getPhone()
    print "getEmail = ", f1.getEmail()
