from number_check import *

"""
show_menu:
    input:
    output: the numerical value that the user has entered
    functionality: This function prints out a menu for the user to see
                   and gets (and returns) a numerical choice from the user.
"""
def show_menu():
    print("1: make new entry")
    print("2: modify existing entry")
    print("3: delete an entry")
    print("4: look up a name")
    print("5: look up a number")
    print("6: quit")

    while True:
        user_choice = get_integer("please select a choice (from 1 to 6): ")
        if (user_choice >= 1) and (user_choice <= 6):
            return user_choice


"""
make_new_entry
    input:
    output:
    functionality: this function asks the user to specify a new entry
                   (new name and phone number) and stores that in the phonebook
"""
def make_new_entry():
    name = input("please enter a name: ")
    number = input("please enter a number: ")

    phonebook = read_phonebook()
    phonebook = add_entry(phonebook, name, number)
    save_phonebook(phonebook)


def read_phonebook():
    input_file = open("phonebook.txt", "r")
    lines = input_file.readlines()
    input_file.close()

    phonebook = []
    for position in range(0, len(lines), 2):
        name = lines[position]
        number = lines[position+1]
        phonebook.append([name, number])

    return phonebook

def main():
    show_menu()


main()
