Ejemplo n.º 1
0
def add_friend():
    new_friend = Spy('', '', 0, 0.0)
    new_friend.name = raw_input("please add your friends name : ")
    new_friend.salutation = raw_input("are they mr or miss : ")
    new_friend.age = int(raw_input("age: "))
    new_friend.rating = float(raw_input("rating: "))
    if len(new_friend.name) > 0 and new_friend.age > 12 and new_friend.rating >= spy.rating:
        friends.append(new_friend)
    else:
        print("sorry! invalid entry. we can't add a spy with the details you provided. please try again later. ")
    return len(friends)
Ejemplo n.º 2
0
                elif mainmenu_choices == 6:
                    read_history()
                elif menu_choice == 7:
                    number = select_a_friend()
                    remove_friend(number)
                else:
                    show_mainmenu = False
    else:
        print "sorry you are of ineligible age to spy"


if existing.upper() == 'Y':
    start(spy)
else:

    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input("welcome, please tell your spy name")

    if len(spy.name) > 0:
        spy.salutation = raw_input("how do you want to be reffered as: ?")

        spy.age = raw_input("what is your age")
        spy.age = int(spy.age)

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

        start(spy)
    else:
        print "please enter valid spy name"
Ejemplo n.º 3
0
    else:
        print "Your age is not suitable."

if existing.upper() == "Y":
    password= raw_input('enter your password!')
    if password =='admin':
        start_chat(spy)
    else:
        print 'password incorrect!'

else:
    spy = Spy('','',0,0.0)
    spy.name = raw_input("Welcome to spy chat. Please enter your name.")

    if set('[~!@#$%^&*()_+{}":;\']+$ " "').intersection(spy.name):
        print "Invalid entry. "
        spy.name = raw_input("Please re enter a valid name!")
    else:
        print spy.name

    if len(spy.name) > 0:
        spy.salutation = raw_input("How would you like us to address you?  ")
        spy.age = raw_input("How old are you?")
        spy.age = int(spy.age)
        spy.rating = raw_input("Let us know your rating.")
        spy.rating = float(spy.rating)
        start_chat(spy)
    else:
        print "Add a valid spy name please."
Ejemplo n.º 4
0
                elif menu_choice == 5:
                    read_chat_history()

                else:
                    show_menu = False
                    print 'Invalid Selection'
    else:
        print 'sorry you not of the correct sage to be spy'


if existing == "Y":

    start_chat(Spy)

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

    spy.name = raw_input("welcome to spy chat,you must tell your name first: ")
    if len(spy.name) > 0:
        spy.salutation = raw_input("what should i call you Mr or Ms? ")

        spy.age = raw_input("Whats your Age? ")
        spy.age = int(spy.age)

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

        spy.spy_is_online = True

        start_chat(spy)
Ejemplo n.º 5
0
Archivo: main.py Proyecto: mudra19/spy
    if len(spy.name) < 0 and spy.name.isspace():

        print "A spy needs to have a valid name.try again please...."

    else:

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

        spy.name = spy.salutation + " " + spy.name

        print "Alright " + spy.name + ". I'd like to know a little bit more about you before we proceed..."

        #get information regarding age,rating and online status from the user

        spy.age = int(raw_input('enter your age: '))

        #check if the age is appropriate

        if spy.age > 12 and spy.age < 50:

            #take spy rating as an input from user otherwise print else statement

            spy.rating = float(raw_input('Enter your rating: '))

            #according to spy rating analyse the nature of spy

            if spy.rating >= 4.5:
                print 'You are an ace!'

            elif spy.rating < 4.5 and spy.rating >= 3.5:
Ejemplo n.º 6
0
def basic_info():
    new_spy = Spy("", "", 0, 0.0)                                                                                       # Object of type Spy class.

    #Taking spy name and displaying a welcome message.
    #.................................................
    loop_count = 0
    while(True):                                                                                                        # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly.
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Bye bye."
            exit()

        loop_count = loop_count + 1
        new_spy.name = raw_input("Please tell me your name? ")
        new_spy.name = new_spy.name.strip()                                                                             # Removes extra whitespaces.
        if len(new_spy.name) > 0:                                                                                       # Checking for blank name.
            print 'Welcome ' + new_spy.name + '. Glad to have you back with us.'
            break
        else:
            print "Please enter a valid name. "
    #.................................................




    #Ask salutation for the spy and error handling.
    #.............................................
    loop_count = 0
    while(True):                                                                                                        # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly.
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Bye bye."
            exit()

        loop_count = loop_count + 1
        new_spy.salutation = raw_input("What should we call you (Mr. or Ms.)? ")                                        # Asking salutation.
        new_spy.salutation = new_spy.salutation.strip()                                                                 # Removing extra whitespaces.
        if len(new_spy.salutation) > 0:
            new_spy.name = new_spy.salutation + " " +new_spy.name                                                       # updating spy name with salutation.
            print "Alright " + new_spy.name + ". I'd like to know a little bit more about you before we proceed..."
            break
        else:
            print "Please enter a valid salutation."
    #.............................................




    #Ask spy for his/her age.
    #........................
    loop_count = 0
    while(True):                                                                                                        # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly.
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Bye bye."
            exit()

        loop_count = loop_count + 1
        new_spy.age = raw_input("What is your age? ")                                                                   # asking age.
        new_spy.age = new_spy.age.replace(" ", "")                                                                      # Removing extra whitespaces.
        try:
            new_spy.age = int(new_spy.age)                                                                              # updating spy age and handling if not an integer.
            break
        except:
            print "Please enter a valid age."

    if new_spy.age <= 12 or new_spy.age >= 50:                                                                          # age should be between 12 and 50.
        print "Sorry you are not of the correct age to be a spy "
        exit()
    #........................




    #Ask spy for his/her rating
    #..........................
    loop_count = 0
    while(True):                                                                                                        # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Bye bye."
            exit()

        loop_count = loop_count + 1
        new_spy.rating = raw_input("What is your spy rating? ")                                                         # asking spy_rating.
        new_spy.rating = new_spy.rating.replace(" ", "")                                                                # Removing extra whitespaces.
        try:
            new_spy.rating = float(new_spy.rating)                                                                      # updating spy age and handling if not a float.
            if 0 <= new_spy.rating <= 5.0:                                                                              # handling if spy_rating entered is greater than 5.
                break
            else:
                print "We are expecting rating from 0 t0 5."
        except:
            print "Please enter a valid rating."

    if new_spy.rating > 4.5:                                                                                            # Complementry message according to spy_rating.
        print "Great ace!"
    elif 3.5 < new_spy.rating <= 4.5:
        print "You are one of the good ones."
    elif 2.5 <= new_spy.rating <= 3.5:
        print "You can always do better."
    else:
        print "We can always use somebody to help in the office."
    #.........................

    return new_spy
Ejemplo n.º 7
0
def friend_info(user_spy_rating):
    new_friend = Spy("", "", 0, 6.0)                                                                                    # new friend of type Spy class.


    # Asking for friend's name.
    # .................................................

    loop_count = 0
    while True:                                                                                                         # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly.
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Try again."
            return new_friend
        loop_count = loop_count + 1

        new_friend.name = raw_input("Please add your friend's name: ")
        new_friend.name = new_friend.name.strip()                                                                       # Removes extra whitespaces.
        if len(new_friend.name) > 0:                                                                                    # Checking for blank name.
            break
        else:
            new_friend.name = ""
            print "Please enter a valid name. "
    # .................................................




    # Ask salutation for the friend and error handling.
    # .............................................
    loop_count = 0
    while True:                                                                                                         # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly.
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Try again."
            return new_friend
        loop_count = loop_count + 1

        new_friend.salutation = raw_input("Are they Mr. or Ms.?: ")                                                     # Asking salutation.
        new_friend.salutation = new_friend.salutation.strip()                                                           # Removing extra whitespaces.
        if len(new_friend.salutation) > 0:
            new_friend.name = new_friend.salutation + " " + new_friend.name                                             # updating friend name with salutation.
            break
        else:
            new_friend.salutation = ""
            print "Please enter a valid salutation."
    # .............................................




    # Ask spy for friend's age.
    # ........................
    loop_count = 0
    while True:                                                                                                         # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly.
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Try again."
            return new_friend
        loop_count = loop_count + 1

        new_friend.age = raw_input("Age? ")                                                                             # asking age.
        new_friend.age = new_friend.age.replace(" ", "")                                                                # Removing extra whitespaces.
        try:
            new_friend.age = int(new_friend.age)                                                                        # updating friend age and handling if not an integer.
            break
        except:
            new_friend.age = 0
            print "Please enter a valid age."

    if new_friend.age <= 12 or new_friend.age >= 50:                                                                    # age should be between 12 and 50.
        new_friend.age = 0
        print "Sorry your friend is not of the correct age to be a spy "
        return new_friend
    # ........................




    # Ask spy for friends rating
    # ..........................
    loop_count = 0
    while True:                                                                                                         # loop for handling invalid input cases.
        if loop_count > 4:                                                                                              # escaping from infinite cases. If someone do knowingly.
            print "You are too DUMB to be a SPY or your keyboard need to be repaired, Try again."
            return new_friend
        loop_count = loop_count + 1

        new_friend.rating = raw_input("Spy rating? ")                                                                   # asking spy_rating.
        new_friend.rating = new_friend.rating.replace(" ", "")                                                          # Removing extra whitespaces.
        try:
            new_friend.rating = float(new_friend.rating)                                                                # updating spy age and handling if not a float.
            if user_spy_rating <= new_friend.rating <= 5:                                                               # handling if spy_rating entered is greater than 5.
                break
            elif new_friend.rating < user_spy_rating:                                                                   # If friends rating is less than spy.
                new_friend.rating = 6
                print "Can not be your friend rating is less. "
                break
            else:
                new_friend.rating = 6
                print "We are expecting rating out of 5"
        except:
            new_friend.rating = 6                                                                                       # Not entered a float Value.
            print "Please enter a valid rating."

    # ............................
    return new_friend
Ejemplo n.º 8
0
    # spy_name is a variable used to store the name entered
    spy.name = raw_input(
        colored('Welcome to spy chat, you must tell me your spy name first:',
                'red'))

    if len(spy.name) > 0:

        # we have used "+" sign to concat that is join the name with the message
        print 'Welcome ' + spy.name + '. Glad to have you back with us.'

        # spy_salutation is a variable
        spy.salutation = raw_input(
            colored("what should we call you (Mr. or Ms. ?)", 'red'))

        # raw_input always gives us a string
        spy.age = raw_input(colored("What is your age?", 'red'))

        # type conversion from string to integer
        spy.age = int(spy.age)

        spy.rating = raw_input(colored("What is your spy rating?", 'red'))

        # type conversion from string to float
        spy.rating = float(spy.rating)

        # nested if-else
        if spy.rating > 4.5:
            print colored('Great ace!', 'red')

        # other way to write
        # elif 3.5 < spy.rating <= 4.5
Ejemplo n.º 9
0
total_reads = 0
avg = 0

user = raw_input(
    "Do you want to continue as default user i.e [%s. %s] (y/n)? " %
    (spy.salutation, spy.name))
if user.lower() == "y":
    print "Authentication completed."
    print 'Welcome %s. %s, your age is %d with rating %.2f' % (
        spy.salutation, spy.name, spy.age, spy.rating)
    old = 1  #Further used to check the defualt user or new user.
elif user.lower() == "n":
    new_spy = Spy('', '', 0, 0.0)  #Creating object for class 'Spy'
    name = raw_input("Enter name: ")
    salutation = raw_input("Enter salutation: ")
    new_spy.age = int(raw_input("Enter your age: "))
    new_spy.rating = float(raw_input("Enter your rating: "))
    count = 0
    if name.isdigit() or name == "" or name.isspace(
    ):  #Checking for valid name input.
        count = count + 1
    if count != 0:
        print "\nWARNING: Invalid name entented"
        exit()
    count = 0
    for i in salutation:  #Checking for valid salutation input.
        if salutation.isdigit() or salutation == "" or salutation.isspace():
            count = count + 1
    if count != 0:
        print "\nWARNING: Invalid saluation entented"
        exit()
Ejemplo n.º 10
0
def add_friend():

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

    addmore = True
    while addmore:  # to add more than one Spy friend

        # Asking Spy Friend's Details

        new_friend.salutation = raw_input(
            "Please add your SPY friend's salutation: ")
        new_friend.name = raw_input("Enter friend's Name: ")
        new_friend.age = input("Age: ")
        new_friend.rating = input("and Spy rating: ")

        # Validating new spy eligibility

        if len(new_friend.name) > 0:
            if new_friend.age > 12 and new_friend.age <= 50:

                if new_friend.name.isalpha():

                    if new_friend.rating >= spy.rating:

                        # adding new friend to the friend list
                        friend_list.insert(len(friend_list), new_friend)

                        print "\n %s %s is added to the SPY CHAT! \n" % (
                            new_friend.salutation, new_friend.name)

                    else:
                        message_box(
                            "Sorry! you aren't eligible to add friends \n Your Rating is not so high ",
                            "Oops", 0)

                else:
                    message_box("Please enter a valid name", "Oops", 0)
            else:
                message_box(
                    "Sorry! your age is not to be a spy \n Please try again",
                    "Oops", 0)

        else:
            # if friend is not provide your spy friend's name
            message_box("Sorry! you must provide your spy friend name.",
                        "Oops", 0)

        while True:  # asking for more friends

            more = raw_input("Do you want to add more Spy Friends? (y/n) ")

            if more.upper() == "N":
                addmore = False
                break

            elif more.upper() == "Y":
                break

            else:
                message_box("Please press a valid key (y/n)", "Oops", 0)

    return len(friend_list)
Ejemplo n.º 11
0
# register a new user other than default user
if question.lower() == "n":

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

    new_user.salutation = raw_input(
        "Should I call you Mister or Miss?: ")  # Salutation for new user

    new_user.name = raw_input("Your name is " +
                              new_user.salutation)  # Salutation for new user

    new_user.name = new_user.salutation + " " + new_user.name

    print "Alright " + " " + new_user.name + ". I'd like to know a little bit more about you before we proceed."

    new_user.age = 0
    new_user.rating = 0.0
    new_user.is_online = False

    new_user.age = int(raw_input("What is your age?"))  # age for new user
    if 50 > new_user.age > 12:
        new_user.rating = float(
            raw_input("What is your rating?"))  # rating for new user
        if 4.5 < new_user.rating:
            print 'Great ace!'
        elif 3.5 < new_user.rating <= 4.5:
            print 'You are one of the good ones.'
        elif 2.5 <= new_user.rating <= 3.5:
            print 'You can always do better'
        else:
            print 'We can always use somebody to help in the office.'
Ejemplo n.º 12
0
            # Check if the name is entered or not
            if len(spy.name) > 0 and spy.name.isdigit() == False:
                # ask for the salutation
                while True:
                    spy.salutation = raw_input(
                        "What should we call you Mr. or Ms.?:-")

                    # check if salutation is entered correct or not
                    if (spy.salutation == 'ms.' or spy.salutation == 'Ms.'
                            or spy.salutation == "Mr."
                            or spy.salutation == "mr."):

                        # Ask for the age of the spy
                        while True:
                            spy.age = raw_input("Please enter your age:-")

                            #when age of spy is not blank ,greater than 0
                            if len(spy.age) > 0:
                                # raw input always gives a string to typecast age to int.
                                spy.age = int(spy.age)
                                #when age of spy is between 18 and 50
                                if 18 < spy.age < 50:
                                    # Ask for spy_rating
                                    while True:
                                        spy.rating = raw_input(
                                            "Please enter your spy rating:- ")
                                        #when rating is greater than 0 then
                                        if len(spy.rating) > 0:
                                            # raw input always gives a string to typecast rating to float.
                                            spy.rating = float(spy.rating)
Ejemplo n.º 13
0
) == "Y":  # For default user the app will import the details from spy_details.py
    start_chat(spy)

else:  # For new user app will ask for the name of the user
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input(
        "Welcome to spy chat, you must tell me your spy name first: ")

    # It checks that the user has not entered an invalid name as input
    if len(spy.name) > 0:
        spy.salutation = raw_input(
            "Should I call you Mr. or Ms.?: "
        )  # The app  ask for the salutaion the user wants to be used in front of their name

        spy.age = raw_input(
            "What is your age?"
        )  # Ask the user for their age and convert it to integer type
        spy.age = int(spy.age)

        spy.rating = raw_input(
            "What is your spy rating?"
        )  # Ask the user for their rating and convert it to float
        spy.rating = float(spy.rating)
        if spy.rating > 4.5:
            print 'Great ace!'
        elif spy.rating > 3.5 and spy.rating <= 4.5:
            print 'You are one of the good ones.'
        elif spy.rating >= 2.5 and spy.rating <= 3.5:
            print 'You can always do better'
        else:
            print 'We can always need somebody to help others in the office.'
Ejemplo n.º 14
0
    start_chat(spy)
else:

    spy = Spy(
        '', '', 0, 0.0
    )  #is the existing spy is not Mr.Bond then new entry of spy is made under constraints

    spy.name = raw_input(
        "Hey pal ! Welcome to spy chat, may i know your spy name first: ")

    if len(spy.name) > 0:

        if set('[~!@#$%^&*()_+{}":;\']+$ " "').intersection(spy.name):
            print "Invalid name."
        else:
            print "Valid name!"
            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 'Great ace!'
            elif spy.rating > 3.5 and spy.rating <= 4.5:
                print 'You are one of the good ones.'
            elif spy.rating >= 2.5 and spy.rating <= 3.5:
                print 'You can always do better'
            else:
                print 'We can always use somebody to help in the office.'
            start_chat(spy)
    else:
        print 'Please add a valid spy name !'
Ejemplo n.º 15
0
            spy.age) + 'having rating of: ' + str(spy.rating)
        spy_chat(spy.name, spy.age, spy.rating)
    else:
        print 'Wrong name or password..'
elif spy_exist == 'Y':
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input('What is your spy name? ')
    print spy.name
    if len(spy.name) > 2:
        print 'Welcome ' + spy.name + '.'
        spy.salutation = raw_input('What should we call you Mr. or Ms.?')
        if spy.salutation == 'Mr.' or spy.salutation == 'Ms.':
            spy.name = spy.salutation + ' ' + spy.name
            print 'Welcome ' + spy.name + '.Glad to see you back..'
            print 'Alright ' + spy.name + '.I would like toknow a little bit more about you.'
            spy.age = input('What is your age ?')
            if 12 < spy.age < 50:
                print 'Your age is correct..'
                spy.rating = input('What is your rating ?')
                if spy.rating > 5.0:
                    print 'Great spy..'
                elif 3.5 < spy.rating <= 5.0:
                    print 'Average Spy..'
                elif 2.5 < spy.rating <= 3.5:
                    print 'Bad spy..'
                else:
                    print 'Who hired you..'
                spy.is_online = True
                print 'Authentication is completed..Welcome' + spy.name + 'age: ' + str(
                    spy.age) + 'raitng: ' + str(spy.rating)
                spy_chat(spy.name, spy.age, spy.rating)
Ejemplo n.º 16
0
                elif menu_choice == 5:
                    read_chat_history()
                else:
                    show_menu = False
    else:
        print('Sorry you are not of the correct age to be a spy')


if existing.upper() == "Y":
    start_chat(spy)

elif existing.upper() == "N":

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

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

    if len(spy.name) > 0:
        spy.salutation = input("Should I call you Mr. or Ms.?: ")

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

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

        start_chat(spy)
    else:
        print('Please add a valid spy name')
Ejemplo n.º 17
0
        #This loop is to re ask the user its name just in case he/she doesnot enter the name at first time
        for e in range(1, 3):
            spy = Spy("", "", 0, 0, 0)
            #details about the spy
            spy.name = raw_input("What do you want to be called as a spy?\n")
            if len(spy.name) > 0:

                print "Hello " + spy.name

                spy.salutation = raw_input(
                    "\nHow do you want to be saluted as Mr , Miss or plz mention anyhting else !\n"
                )
                # concatinating name and salutation
                spy.name = spy.salutation + " " + spy.name

                spy.age = raw_input("\nWhat is your age ?\n")
                spy.age = int(spy.age)

                #Authenticating the spy age
                if spy.age > 12 and spy.age < 30:

                    print "\nOk! " + spy.name + " aged " + str(
                        spy.age) + ". Good to have you here :) ."
                    print "\nHow about you tell something more about yourself"

                    #this loop is to reconfirm the spy ratings ..in case user enters wrong credentials
                    for e in range(1, 3):

                        spy.rating = raw_input("\nWhat is your spy rating\n")
                        spy.rating = float(spy.rating)
Ejemplo n.º 18
0

spy_exist = raw_input('Are you an existing spy Y/N '
                      )  #asking the user whether he/she is an spy or not
if spy_exist.upper() == 'Y':  #conditional Statement
    print 'Welcome back %s age: %d having spy rating of %d' % (
        spy.name, spy.age, spy.rating
    )  #Displaying the previous data for the user
    start_chat(spy.name, spy.age, spy.rating)  #Calling  a  chat function
elif spy_exist.upper() == 'N':  #conditional Statement
    spy = Spy("", "", 0, 0.0)
    spy.name = raw_input(
        'Enter Your Name ')  #Message for the user and input from the user

    spy.rating = 0.0  #Initalising the variable
    spy.age = 0  #Initalising the variable
    if spy.name.isalpha():  #Checking for name entered by the user as input
        spy.salutation = raw_input(
            'What should we call you(Mr. or Ms.)'
        )  # Message for the user and input from the user
        if len(
                spy.name
        ) >= 2:  #Checking the length of the name which should be greater than two
            if spy.salutation.upper() == 'MR.' or spy.salutation.upper(
            ) == 'MS.':  #conditional Statement
                spy.name = spy.salutation.upper() + '' + spy.name.upper(
                )  #Concatinationg  2 string
                print 'Welcome ' + spy.name + ' Glad to have you back with us'  ##Concatinationg  2 string
                print 'Alright ' + spy.name + '. ' + 'I\'d like to know a little bit more about you ...'  #Concatinationg  2 string
                spy.age = input(
                    'what is your age ')  #input taken from the user