コード例 #1
0
ファイル: main.py プロジェクト: sagarkava/spychat
def add_friend():
    frnd = Spy('', '', 0, 0.0)
    frnd.name = raw_input('What is your friend name?-> ')
    frnd.sal = raw_input('what should we call you? ->')
    frnd.age = input('What is your friend age?->')
    frnd.rating = input('What is your friend rating-> ')
    frnd.is_online = True
    if len(frnd.name) > 2 and 12 < frnd.age < 60 and frnd.rating > spy.rating:
        with open('friends.csv', 'a') as (friends_data):
            writer = csv.writer(friends_data)
            writer.writerow(
                [frnd.name, frnd.sal, frnd.rating, frnd.age, frnd.is_online])

    else:
        print 'Friend cannot be added'
    return len(friends)
コード例 #2
0
def add_friend():
    frnd = Spy('', '', 0, 0.0)
    frnd.name = raw_input("enter the friend name: ")
    frnd.sal = raw_input("salutaion? Mr. or Ms.")
    frnd.age = input("friend age? ")
    frnd.rating = input("friend rating? ")
    frnd.is_online = True
    if len(frnd.name) > 0 and 65 > spy.age > 16 and frnd.rating > spy.rating:
        with open('friends.csv', 'ab') as friend_data:
            writer = csv.writer(friend_data)
            writer.writerow(
                [frnd.name, frnd.sal, frnd.rating, frnd.age, frnd.is_online])
            print "congrats...Now you have one more frirnd"
    else:
        print "friend cannot be added"
    return len(friends)
コード例 #3
0
    else:
        print 'Sorry you are not of the correct age to be a spy'


if (exist == "Y" or exist == "y"):  # if existing user
    print "Welcome " + spy.salutation + " " + spy.name + " your age is " + str(
        spy.age) + " and rating is " + str(spy.rating)
    spy_chat(spy)  # calling of function

elif (exist == "N" or exist == "n"):  # if not a existing user
    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 and spy.name.isspace() == False:
        spy.salutation = raw_input("What should i call you Mr. or Ms.")
        if spy.salutation == "Mr." or spy.salutation == "Ms.":
            spy.age = int(raw_input("Enter your age"))
            spy.rating = float(raw_input("what is your spy rating"))
            spy.is_online = True
            spy_chat(
                spy
            )  # calling start_chat function to start the chat application
        else:
            print "enter valid salutation!!"

    else:
        print 'Please add a valid spy name'  # if spy press enter without giving any name

else:
    print "invalid choice!!!"