示例#1
0
def add(bd: BD) -> BD:
    pers = Person()
    pers.set_name(input('Input name: '))
    pers.set_surname(input('Input surname: '))
    birth = input("Add birthday? Y/N")
    if birth == 'Y':
        pers.set_birthday_date(input("Input birthday date: dd.mm.yyyy : "))
    ph = 'Y'
    while ph == 'Y':
        pers.add_phone(input('Input new phone name:\t'),
                       input('Input new phone number'))
        ph = input('Add other phone? Y/N')
    bd.add(pers)
    fileworker.write_to_end(pers)
    return bd
示例#2
0
from person import Person
from BD import BD
from FileWorker import FileWorker

p1 = Person()
p1.set_name('Max')
p1.set_surname('Moshkov')
p1.set_birthday_date('10.11.1770')
p1.add_phone('tel_1_1', '89026810084')
p1.add_phone('tel_2_1', '89023000910')

p2 = Person()
p2.set_name('Maxim')
p2.set_surname('Moshkov')
p2.set_birthday_date('25.05.1975')
p2.add_phone('tel_1_2', '89026810085')
p2.add_phone('tel_2_2', '89023000910')

bd = BD()
bd.add(p1)
bd.add(p2)

print(bd)

people = bd.get_all()
for p in people:
    print(p)

print()

print(bd.search(name='Max'))