# Written By: Arup Guha
# Translated By: Tyler Woodhull
# 6/1/13
# Contact.py
# Slightly edited on 6/4/2024

class Contact:
    
    name = "" # Stores name of Contact
    age = 0 # Stores age of Contact
    phonenumber = 0 # Stores phone number of Contact
    bday = 0 # Stores birthday in an int

    # Creates Contact object based on parameters.
    def __init__(self, n, a, p, month, day):
        self.name = n
        self.age = a
        self.phonenumber = p
        self.bday = 100 * month + day

    # Changes phone number of contact
    def changeNumber(self, newnum):
        self.phonenumber = newnum

    # Implements the passing of the Contact's birthday.
    def Birthday(self):
        self.age += 1

    # Returns the name of the Contact
    def getName(self):
        return self.name

    # Returns the age of a Contact
    def getAge(self):
        return self.age

    # Returns the phone number of a Contact
    def getNumber(self):
        return self.phonenumber

    # Returns month of Contact's birthday
    def getBdayMonth(self):
        return self.bday//100

    # Returns day of the month of Contact's birthday
    def getBdayDay(self):
        return self.bday%100

    # Contact has a birthday.
    def celebrateBirthday(self):
        self.age += 1


    # Prints all information about a Contact out.
    def printContact(self):
        print("In printContact")
        print("Name: " + self.name + " Age: " + str(self.age))
        print("Phone#: " + str(self.phonenumber))
        print("Birthday: " + str(self.getBdayMonth()) + "/" + str(self.getBdayDay()))
        print()
        
    # Prints all information about a Contact out.
    def __str__(self):
        ans = "Name: " + self.name + " Age: " + str(self.age) + "\n"
        ans = ans + "Phone#: " + str(self.phonenumber) + "\n"
        ans = ans + "Birthday: " + str(self.getBdayMonth()) + "/" + str(self.getBdayDay())+"\n"
        return ans

# A small test
def testContact():

    # I have his bobblehead on my desk at home!
    lionel = Contact("LionelMessi", 36, 9999999999, 6, 24)

    # Invokes the __str__ method
    print(lionel)

    # This method is unnecessary, but I'm showing the difference syntactically.
    # Whereas __str__ is special, printContact is a regular void method.
    lionel.printContact()

    # Give him a birthday.
    lionel.celebrateBirthday()
    print("After his birthday, here is Leo's information:")
    print(lionel)

    # Leo gets a Miami phone number!
    lionel.changeNumber(3059999999)
    print("Leo avoids being found by changing his number:")
    print(lionel)

# Run it!
testContact()
