예제 #1
0
def main():
    global hash, s
    global q

    with open("new_stations.json") as data_file:
        dictionary = json.load(data_file)
        hash = dict_to_hashmap(dictionary)

    s = SingleLinkedList()
    q = Queue()

    choice_1 = question_1()

    if int(choice_1) == 1:
        choice_1_1 = question_1_1()

        if int(choice_1_1) == 1:
            my_des = question_1_1_1()
            work(my_des)

        if int(choice_1_1) == 4:
            main()

    if int(choice_1) == 3:
        choice_1_3 = question_1_3()

        if int(choice_1_3) == 1:
            question_1_3_1()

        if int(choice_1_3) == 2:
            choice_1_3_2 = question_1_3_2()

            if int(choice_1_3_2) == 1:
                question_1_3_2_1()

            if int(choice_1_3_2) == 2:
                question_1_3_2_2()

            if int(choice_1_3_2) == 3:
                question_1_3_2_3()

            if int(choice_1_3_2) == 4:
                question_1_3()

        if int(choice_1_3) == 3:
            choice_1_3_3 = question_1_3_3()

            if int(choice_1_3_3) == 1:
                question_1_3_3_1()

            if int(choice_1_3_3) == 2:
                q.display()
                question_1_3_3_2()

            if int(choice_1_3_3) == 3:
                main()

        if int(choice_1_3) == 4:
            question_1()
예제 #2
0
def question_1_3_2_3():  # save all
    choose_folder_and_convert_all_music_to_list_and_json()
    with open("music_library.json") as data_file:
        dictionary = json.load(data_file)
    music = SingleLinkedList()
    for e in dictionary["music"]:
        music.insertLast(e)
    cur_node = s.first
    while cur_node is not None:
        music.insertLast(cur_node.data)
        cur_node = cur_node.next
    with open('music_library.json', "w") as file:
        json.dump(music.to_json(), file, indent=2)
    music.remove_all()
    s.remove_all()
예제 #3
0
def question_1_3_2_1():  # save choice
    folder = choose_folder_and_convert_all_music_to_list_and_json()
    if folder is False:
        question_1_3_2_2()
    else:
        choice = str(display_nth_item_folder(folder))
        with open("music_library.json") as data_file:
            dictionary = json.load(data_file)
        music = SingleLinkedList()
        for e in dictionary["music"]:
            music.insertLast(e)
        music.insertLast(choice)
        with open('music_library.json', "w") as file:
            json.dump(music.to_json(), file, indent=2)
        music.remove_all()
        s.remove_all()
예제 #4
0
                question_1_3_2_3()

            if int(choice_1_3_2) == 4:
                question_1_3()

        if int(choice_1_3) == 3:
            choice_1_3_3 = question_1_3_3()

            if int(choice_1_3_3) == 1:
                question_1_3_3_1()

            if int(choice_1_3_3) == 2:
                question_1_3_3_2()

            if int(choice_1_3_3) == 3:
                main()

        if int(choice_1_3) == 4:
            question_1()


with open("Stations.json") as data_file:
    dictionary = json.load(data_file)
    hash = dict_to_hashmap(dictionary)

s = SingleLinkedList()
q = Queue()

while True:
    main()