'''
Created on Jun 17, 2013

@author: Jared

A short example to illustrate the use of the string comparisons.
The user is asked to input two names (both first and last for each)
and the proper alphabetical order of the two names is outputted.

Python translation of Arup's Java code
'''

# Constants to indicate the relation between the two entered names.
FIRST = 0
LAST = 1
TIE = 2

def main(): 
    # Get user input.
    fName1 = input("What is the first person's first name?\n")
    lName1 = input("What is the first person's last name?\n")
    fName2 = input("What is the second person's first name?\n")
    lName2 = input("What is the second person's last name?\n")

    # First compare last names.
    # Deals with the case of different last names.
    if (lName1 < lName2):
        first_name = FIRST
    elif (lName1 > lName2):
        first_name = LAST
        
    # Compares first names since the last names are identical.
    else:
        # Determine the appropriate order from the comparison.
        if (fName1 < fName2):
            first_name = FIRST
        elif (fName1 > fName2):
            first_name = LAST
        else:
            first_name = TIE

    # Print out the appropriate order of names.
    if (first_name == FIRST):
        print(fName1 + " " + lName1 + " comes alphabetically" + " before " + fName2 + " " + lName2)
    elif (first_name == LAST):
        print(fName2 + " " + lName2 + " comes alphabetically" + " before " + fName1 + " " + lName1)
    else:
        print("Both people have the identical name!!!")
              
# runs main module on startup
if __name__ == "__main__":
    main()
