spy = Spy("Bond", "Mr.", 30, 4.8) # Assigning our default spy some number of statuses to choose from pool of statuses spy.pool_of_status = ["I'm Bond", "At your service", "bow down to the king"] # Assigning our spy some friends # we create to Spy objects and assign them name "friend1" & "friend2" # we then add these friends to spy's friend list friend1 = Spy("Paras", "Mr", 21, 4.99) friend2 = Spy("holmes", "Mr", 21, 2.99) spy.add_spy_friend(friend1) spy.add_spy_friend(friend2) # Asking user to continue as the spy we made above choice = input("Do you want to continue as {} {} (Y or N) ".format( spy.get_salutation(), spy.get_name())) # Checking if user is a default one or not if choice == "Y" or choice == "y": ask_for_info = False else: ask_for_info = True # if user was not the default one we let the "make_a_spy" method handle the task of collecting spy info # otherwise welcome him as default spy if ask_for_info: spy = make_a_spy() # Welcome the spy (We use the spy object and its methods) print("Welcome {} {} age : {}, rating : {:0.2f}".format( spy.get_salutation(), spy.get_name(), spy.get_age(), spy.get_rating()))
# creating a default spy with parameters as under spy = Spy("Bond", "Mr.", 30, 4.8) # Assigning our default spy some number of statuses to choose from pool of statuses spy.pool_of_status = ["I'm Bond", "At your service", "bow down to the king"] # Assigning our spy some friends # we create to Spy objects and assign them name "friend1" & "friend2" # we then add these friends to spy's friend list friend1 = Spy("Paras", "Mr", 21, 4.99) friend2 = Spy("Sam", "Mr", 21, 2.99) spy.add_spy_friend(friend1) spy.add_spy_friend(friend2) # Asking user to continue as the spy we made above choice = input("Do you want to continue as {} {} (Y or N) ".format(spy.get_salutation(), spy.get_name())) # Checking if user is a default one or not if choice == "Y" or choice == "y": ask_for_info = False else: ask_for_info = True # if user was not the default one we let the "make_a_spy" method handle the task of collecting spy info # otherwise welcome him as default spy if ask_for_info: spy = make_a_spy() # Welcome the spy (We use the spy object and its methods) print("Welcome {} {} age : {}, rating : {:0.2f}" .format(spy.get_salutation(), spy.get_name(), spy.get_age(), spy.get_rating()))