Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #6
0
def add_friend():
    frnd = Spy("", "", 0, 0.0)
    firstname = raw_input("enter your friends name ")
    frnd.sal = raw_input("enter friend salutation:")
    frnd.age = input("enter age of friend::")
    frnd.rating = input("enter rating:")
    frnd.name = frnd.spy + " " + frndname
    if len(frnd.name
           ) >= 2 and 12 < frnd.age < 60 and frnd.rating >= spy.rating:
        friends.append(frnd)
    else:
        print "Sorry enter Valid Details"
        return len(friends)
Exemple #7
0
def signup():
    spy = Spy("", "", 0, 0.0)  # class for spydetails
    spy.name = raw_input(
        'Enter your username: '******'Enter a valid name '
    elif spy.name.isdigit():  # to check for digit input
        print 'Enter a valid name '
    elif len(spy.name) > 2:  # checking for length of the string name
        password = raw_input("Enter your password: "******" " + spy.name
            print 'Alright ' + spy_name + '. I\'d like to know a little bit more about you...'
            spy.age = input('What\'s your age :  ')
            if 50 <= spy.age <= 12:  # nested if statement to check range of age
                print 'You are not eligible to be a spy.'
            else:
                spy.rating = input(
                    'What are your ratings : ')  # taking ratings as input
                if spy.rating > 5:
                    print 'Great Spy!!'
                elif spy.rating > 3.5:  # elif statement for more than one condition
                    print 'Average Spy.'
                elif spy.rating > 2.5:
                    print 'Need to work hard!!'
                else:
                    print 'Who hired you'
                spy_is_online = True
                print 'Authentication complete. Welcome ' + spy_name + '.Your age is ' + str(
                    spy.age) + ' and your rating is ' + str(
                        spy.rating)  # typecasting of integer to string
                # writing details in login file
                with open("login.csv", "ab") as login:
                    writer = csv.writer(login)
                    writer.writerow([
                        spy.name, password, spy.sal, spy.age, spy.rating,
                        spy_is_online
                    ])

                spy_chat(spy_name, spy.age,
                         spy.rating)  # calling function spy_chat

        else:
            print 'Enter a valid salutation'

    else:
        print 'Ooops! Enter a valid name '
Exemple #8
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)
Exemple #9
0
def add_friend():

    new_friend = Spy('', '', 0, 0.0)
    new_friend.name = raw_input('Please add your friend\'s name :')
    new_friend.salu = raw_input('are they Mr or Miss ? :')
    new_friend.age = int(raw_input('age:'))
    new_friend.rating = float(raw_input('spy rating'))
    if (new_friend.name.isalpha()
        ) and new_friend.age > 12 and new_friend.rating >= spy.rating:
        #add friend into friend list
        friends.append(new_friend)

    else:
        print 'Sorry! invalid entry.We can\'t add spy with the detalis you provided '
    return len(friends)
Exemple #10
0
def add_friend():  #  function to add friend
    #  taking friend detail as input
    frnd = Spy("","",0,0.0)  #  class for details of friend
    frnd.name = raw_input("What is your friend's name :")
    frnd.sal = raw_input("What is your friends salutation")
    frnd.age = input("What is the age :")
    frnd.rating = input("What are the rating :")
    frnd.is_online = True
    if len(frnd.name)>0 and 12<frnd.age<50 and frnd.rating > spy.rating:
        #  adding the details in the respective lists
        with open('friend.csv','ab')as friend_data:
        writer = csv.writer(friend_data)
        writer.writerow([frnd.sal,frnd.age,frnd.rating,frnd.is_online])
        print "Your frnd is added"
        friends.append(frnd)  #  appending friend details in friend list
    else:
        print "The friend cannot be added "
    return len(friends)  #  retuning length of list friend_name
Exemple #11
0
def signup():
    spy = Spy("","",0,0.0)  #class for spy details
    spy.name = raw_input("Enter your name ")  #  name taken as input from user
    if spy.name.isspace():  #  check for space input
        print ' Enter a valid name '
    elif spy.name.isdigit():
        print ' Enter a valid name '
    elif len(spy.name) > 2:  #  checking for length of string
        print " welcome " + spy.name+" "+" Glad to have with us. "   # concatenating strings
        spy.sal = raw_input("What do we call you (Mr. or Ms. or Mrs.)")
        if spy.sal == "Mr." or spy.sal == "Ms." or spy.sal == "Mrs.":  #  condition for checking input salutation
            spy_name = spy.sal+" "+spy.name
            print " Alright " + spy_name + " I\'d like to know little more about you......"
            spy.age = input('what\'s your age')
            if 55 <= spy.age <= 12:  #  nested if to check range of age
                print 'You are not eligible to be a spy'
            else:
                rating = input('enter your ratings ')
                if spy.rating > 5:
                    print 'Great Spy!!!'
                elif spy.rating > 4:
                    print 'Good Spy...!'
                elif spy.rating > 3.5:   #  elif is used for more than one condition
                    print ' Average Spy '
                elif spy.rating > 2.5:
                    print ' Need To Work Hard !!! '
                else:
                    print ' Who Hired You...Get Out !!! '
                spy_is_online = True
                print 'Authentication complete. Welcome ' + spy.name + ' age: ' + str(spy.age) + ' and your rating is : ' + str(spy.rating)  #  typecasting of integer to string
                spy_chat(spy.name, spy.age, spy.rating)   #  calling function spy_chat

        else:
            print ' Enter a valid salutation '
    else:
        print ' Ooops!!  Please enter a valid name. '
Exemple #12
0
                else:
                    #The menu will disappear.
                    show_menu = False
    else:
        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"
Exemple #13
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')
Exemple #14
0
    while (show_menu):
        menu_choice = 'What do you want to do? \n 1. Add a status update \n 2.Add frinend  \n 3.send  a secrrt message \n 4.read a secret message \n 5.read chat history from a user \n 6. close appliction'
        menu_choice = raw_input(menu_choice)
        menu_choice = int(menu_choice)
        if menu_choice == 1:
            print 'You chose to update the status'
            current_status_message = add_status(
                current_status_message)  #calling add _status funtion
        elif menu_choice == 2:
            add_friend()  #calling add _friend funtion
        elif menu_choice == 3:
            send_message()  #calling send_message funtion
        elif menu_choice == 4:
            read_message()  #calling read_message funtion
        elif menu_choice == 5:
            read_chat_history()  #calling read_chat_history  funtion
        elif menu_choice == 6:
            show_menu = False
        else:
            print 'plz enter given choice number'


#this for you are countinue with old spy details Yes or no
question = raw_input('do you want the  countinue yes(Y) or no(N) :')
if (question.upper() == 'Y'):
    print 'okey'
    start_chat()
else:
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input("Enter the name")
    vaildion(spy.name)
Exemple #15
0
        print 'Sorry you are not of the correct age to be a spy'


if existing == "y":  #if user is old then take the old information through import fxn
    from ss import spy_name, spy_salutation, spy_age, spy_ratting

    print spy_name
    print spy_salutation
    print spy_age
    print spy_ratting
    start_chat(spy)
else:  #enter the data for new user
    spy = Spy('', '', 0, 0.0)

    spy.name = str(
        raw_input("Welcome to spy chat, you must tell me your spy name first: "
                  ))  #username of new user
    if spy.name == str(spy.name):
        a = raw_input("what is ur gender (male. 0r female)")  # input gender
        if a == "male":  # nested if statement
            print "mr." + " " + spy.name + " welcome to spy chat"
        else:
            print "miss" + " " + spy.name + " welcome to spy chat"

        spy.age = int(raw_input(
            "What is your age?"))  #check that the age of user is valid or not
        if spy.age > 16 and spy.age < 45:
            d = raw_input("may i know what is ur rating")  # input ratting
            d = float(d)
            if d > 4.5:  # nested if statement for ratting
                print "great"
Exemple #16
0
frnd1 = Spy('ANIL', 'Mr.', 20, 5.3)
frnd2 = Spy('Pooja', 'Ms.', 21, 7.0)
friends = [frnd1, frnd2]  #list of friends
# available status list
STATUS_MESSAGE = ['Sleeping', 'Available', 'Busy', 'At Work']
#asking user if user is already present or not
spy_reply = raw_input('Are you a new user? Y/N')
if spy_reply.upper() == 'N':
    #details of already present user
    print 'Welcome back..!! ' + spy.name + '. Your age is ' + str(
        spy.age) + ' and your rating is ' + str(spy.rating)
    #function calling
    spy_chat(spy.name, spy.age, spy.rating)
if spy_reply.upper() == 'Y':
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input("what is your name?")
    #if user enter space in spy_name
    if spy.name.isspace():
        print 'enter valid name'
    #if user enter digit in spy_name
    elif spy.name.isdigit():
        print "enter valid name"
# Name condition
    elif len(spy.name) >= 2:
        print 'Welcome ' + spy.name + ' Glad to have back with us'
        spy.sal = raw_input("What should we call you (Mr. or Ms.)")
        if spy.sal == 'Mr.' or spy_salutation == 'Ms.':
            spy_name = spy.sal + " " + spy.name
            print "Alright " + spy_name + " I\'d like to know a little more about you before we proceed..."
            spy.age = input("enter your age")
            #Age condition and rating