Ejemplo n.º 1
0
def main():

    phone_name = raw_input("Enter the name of your phone: ")
    number = int(raw_input("Enter your number: "))
    phone = Phone(number, phone_name)
    print "Congratulations! You've set up your phone!"
    while True:
        display_menu()
        choice = raw_input("Please select an action: ")
        if choice == "0":
            display_menu()
        elif choice == "1":
            display_contacts(phone)
        elif choice == "2":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            number = int(raw_input("Enter the contact's number: "))
            phone.add_contact(first_name, last_name, number)
        elif choice == "3":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            phone.del_contact(first_name)
        elif choice == "4":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            phone.call(first_name, last_name)
        elif choice == "5":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            message = raw_input("Enter the text message: ")
            phone.text(first_name, message)
        elif choice == "6":
            break
        else:
            print "Invalid selection. Please choose again."
Ejemplo n.º 2
0
from phone import Phone
from iphone import IPhone
from android import Android

moms_number = "888-3434"
old_phone = Phone("555-1314")
iphone = IPhone("555-0001")
android = Android("555-1337")

# All phones have the call method defined in Phone
old_phone.call(moms_number)
iphone.call(moms_number)
android.call(moms_number)
print("\n")

# All phones have the text method defined in Phone
old_phone.text(moms_number, "Hey Mom. I want a new phone.")
iphone.text(moms_number, "Thanks for the iPhone, Mom!")
android.text(moms_number, "Mom, I saved up and bought an Android.")
print("\n")

# made up strings representing "fingerprints"
my_fingerprint = "swirl whorl whorl"
other_fingerprint = "spiral whorl swirl"

# the iphone has access to it's own unlock and set_fingerprint methods.
iphone.unlock()

iphone.set_fingerprint(my_fingerprint)
iphone.unlock(other_fingerprint)
iphone.unlock(my_fingerprint)