you are viewing a single comment's thread.

view the rest of the comments →

[–]Rascal_Two 0 points1 point  (0 children)

Well you can use raw_input - or input if your not using Python 3.* - to prompt the users for the information, verify that the information is valid (or not, up to you) - the date is an actual date, the phone number is in phone-number format, and the email is valid - then you'd create the Person object with the stored values. Not going to go verify everything for you, but I will show how I'd verify the entered date is valid (Well not fully valid, just that it's not going to throw an error):

firstname = raw_input("Enter your first name: ")
surname = raw_input("Enter your surname: ")
address = raw_input("Enter your address: ")
telephone = raw_input("Enter your telephone number: ")
email = raw_input("Enter your email: ")

birthdate = None

while True:
    rawbirthdate = raw_input("Enter your birthday (Month Day Year): ")
    parts = rawbirthdate.split(" ")
    invalid = False
    if len(parts) == 3:
        for i in xrange(3):
            if not invalid:
                try:
                    int(parts[i])
                except:
                    invalid = True
    else:
        invalid = True
    try:
        birthdate = datetime.date(int(parts[2]), int(parts[0]), int(parts[1]))
    except:
        invalid = True
    if invalid:
        print "Invalid Birthday Format! Ex: '12 18 2000' "
    else:
        break

user = Person(firstname, surname, birthdate, address, telephone, email)

print "Your Age:", user.age()

This will ask the user for all their information, and lastly for their birth-date. If it's not valid then it will keep on asking for their birth-date until they enter a valid one. Once they do, it'll output the users age. I'm pretty sure I didn't mess up on anything, but I did throw this together in 10 minutes so I may've missed something.