示例#1
0
def add_friend():
    new_friend = Spy('','',0,0.0)
#added in the spy class
    new_friend.name = raw_input("Please add your friend's name: ")
    if set('[~!@#$%^&*()_+{}":;\']+$ " "').intersection(new_friend):
        print "Invalid entry."
    else:
        print new_friend

    new_friend.salutation = raw_input("Formal Salutation: Mr. or Ms. or Mrs. ")
    new_friend.name = new_friend.salutation + " " + new_friend.name

    new_friend.age = raw_input("Age?")
    new_friend.age = int(new_friend.age)

    new_friend.rating = raw_input("Spy rating?")
    new_friend.rating = float(new_friend.rating)

    if len(new_friend.name) > 2 and new_friend.age > 15 and new_friend.rating >= spy.rating:
        friends.append(new_friend)
        print 'New Friend Added!'
    else:
        print 'Sorry! Invalid entry. We can\'t add spy with the details you provided!!'

    return len(friends)
示例#2
0
def add_friend():

    new_friend = Spy('','',0,0.0)

    new_friend.name = raw_input("\nPlease add your friend's name: ")
    new_friend.salutation = raw_input("Are they Mr. or Ms.?: ")

    new_friend.name = new_friend.salutation + " " + new_friend.name

    new_friend.age = int(raw_input("Age?"))

    new_friend.rating =float( raw_input("Spy rating?"))

    if len(new_friend.name) > 0 and new_friend.age > 12 and new_friend.rating >= spy.rating:
        friend_list.append(new_friend)
        print 'Friend Added!'

    else:
        print '\nSorry! Invalid entry. We can\'t add spy with the details you provided'

    return len(friend_list)
示例#3
0
def add_friend():
    new_friend = Spy('', '', 0, 0.0)
    new_friend.name = raw_input("Enter friends name")
    new_friend.salutation = raw_input("Are they Mr. or Ms.?: ")

    new_friend.name = new_friend.salutation + " " + new_friend.name

    new_friend.age = raw_input("Age?")
    new_friend.age = int(new_friend.age)

    new_friend.rating = raw_input("Spy rating?")
    new_friend.rating = float(new_friend.rating)
    new_friend.chats = []

    if len(new_friend.name) > 0 and new_friend.age > 12:
        friends.append(new_friend)
        print colored('\nFriends Added', 'yellow', attrs=['bold'])
    else:
        print 'Sorry! Invalid entry. We can\'t add spy with the details you provided'

    return len(friends)
示例#4
0
def add_friend():
    new_friend = Spy('', '', 0, 0.0)

    new_friend.name = input("please ! add your friends name ? ")
    name = new_friend.name
    new_friend.salutation = input("Are they MR OR MS")
    new_friend.name = new_friend.salutation + " " + name
    new_friend.age = int(input("enter age ?"))
    new_friend.rating = float(input("spy rating ?"))

    if len(new_friend.name) > 0:
        print("spy name is not empty")

        if (name_vali(name) is True) and age_val(new_friend.age):
            friends.append(new_friend)

    else:
        print(
            "sorry invalid entry . we can't add spy with details you provided")
    # return the no of friends in dictionary
    return len(friends)
示例#5
0
def add_friend():  #define friend fxn to add new friend
    new_friend = Spy('', '', 0, 0.0)

    new_friend.name = raw_input("Please add your friend's name: ")
    new_friend.salutation = raw_input("Are they Mr. or Ms.?: ")

    new_friend.name = new_friend.salutation + " " + new_friend.name

    new_friend.age = raw_input("Age?")
    new_friend.age = int(new_friend.age)

    new_friend.rating = raw_input("Spy rating?")
    new_friend.rating = float(new_friend.rating)

    if len(new_friend.name) > 0 and int(
            new_friend.age) > 12 and new_friend.rating >= float(spy.rating):
        friends.append(new_friend)
        print 'Friend Added!'
    else:
        print 'Sorry! Invalid entry. We can\'t add spy with the details you provided'

    return len(friends)
示例#6
0
def add_friend():
    #creating empty values for new friend
    new_friend = Spy('', 0, '', 0.0)
    #to evaluate all details of spy's new friend like name, age, rating and salutation
    new_friend.name = raw_input("add your friends name:")
    new_friend.salutation = raw_input("are they Mr. or Ms.:?")

    new_friend.name = new_friend.name + " " + new_friend.salutation

    new_friend.age = int(raw_input("age?"))
    new_friend.rating = float(raw_input("spy rating?"))

    #to check the spy's friend's age, rating and the name that should not be empty

    if len(new_friend.name
           ) > 0 and new_friend.age > 12 and new_friend.rating >= spy.rating:
        friends.append(new_friend)
        print colored('Friend Added!', 'red')
    else:
        print colored(
            'sorry! invalid entry. we can\'t add spy with the details you provided',
            'blue')

    return len(friends)
示例#7
0
        print 'Sorry you are not of the correct age to be a spy\n'


if answer == "Y":
    start_chat(spy)

else:

    spy = Spy('', '', 0, 0.0)

    spy.name = raw_input(
        "Welcome to spy chat, you must tell me your spy name first: ")

    if len(spy.name) > 0:

        spy.salutation = raw_input("Should I call you Mr. or Ms.?: ")

        spy.age = int(raw_input("What is your age?"))

        spy.rating = float(raw_input("What is your spy rating?"))

        if spy.rating > 4.5:
            print "You have a great ace.\n"
        elif spy.rating >= 3.5 and spy.rating <= 4.5:
            print "You can do better.\n"
        else:
            print "We can use someone from the office.\n"

        start_chat(spy)

    else:
示例#8
0
                #if user selects option 6, then close the application
                else:
                    show_menu = False

    else:
        print colored("sorry you are not of the correct age to be a spy",
                      'red')


if question == "Y":
    start_chat(spy)
else:
    #declaring empty values for spy
    spy = Spy('', 0, '', 0.0)

    #to know about the spy while asking all the details like name, salutation, age and rating
    spy.name = raw_input("welcome to spychat. tell me your name:")
    #to check if spy name is not empty
    if len(spy.name) > 0:

        spy.salutation = raw_input("what should we call you(Mr. or Ms.)?")

        spy.age = int(raw_input("what is your age:"))
        spy.rating = float(raw_input("what is your spy rating?"))

        start_chat(spy)

    else:
        print colored("a spy needs to have a valid name. please try again",
                      'blue')