Exemplo n.º 1
0
def display_preferences(data):
    preferences = []
    for items in data:
        name, drink = items[0], items[1]
        preference = f"{name}'s favourite drink: {drink}"
        preferences.append(preference)
    table('PREFERENCES', preferences)
Exemplo n.º 2
0
def remove_drink(header, data):
    not_removed_drink = True
    while not_removed_drink:
        if len(data.values()) == 0:
            print("\nThere are no drinks to remove")
            break
        else:
            drink = Drink()
            table(header, data)
            deleted_drink = drink.remove_drink_from_database(data)
            print(f"You have removed {deleted_drink} from the list of drinks")
            if len(data.values()) > 0:
                not_removed_drink = continue_operation("\nWould you like to remove another drink")
            else:
                print("All drinks have been removed!")
                not_removed_drink = False
Exemplo n.º 3
0
def remove_person(header, data):
    not_removed_person = True
    while not_removed_person:
        if len(data.values()) == 0:
            print("\nThere are no people to remove")
            break
        else:
            person = Person()
            table(header, data)
            name = person.remove_person_from_database(data)
            print(f"Goodbye {name}! See you soon!")
            if len(data.values()) > 0:
                not_removed_person = continue_operation("\nWould you like to remove another person")
            else:
                print("All people have been removed!")
                not_removed_person = False
Exemplo n.º 4
0
    def order(self, people_dic, drinks_dic):
        order_dic = {}
        selected = []
        # pick person and corresponding fave drink
        round_order = True
        while round_order:
            name_table = table('PEOPLE', people_dic)
            not_chosen_person = True
            while not_chosen_person:
                self.person_tag = int(input("\nPlease choose a person: "))
                if self.person_tag not in people_dic.keys():
                    print("\nYou're out of range, try again.")
                else:
                    not_chosen_person = False

            drinks_table = table('DRINKS', drinks_dic)
            not_chosen_drink = True
            while not_chosen_drink:
                self.drink_tag = int(
                    input("\nSelect that person's drink order: "))
                if self.drink_tag not in drinks_dic.keys():
                    print("\nYou're out of range, try again.")
                else:
                    not_chosen_drink = False

            order_dic[people_dic[self.person_tag]] = drinks_dic[self.drink_tag]
            name = people_dic.pop(
                self.person_tag)  # (-1) --> Account for index position
            selected.append(name)
            # CREATE CHECK AGAINST REPEAT PREFERENCE!
            not_chosen_option = True
            while not_chosen_option:
                option = input(
                    "\nWould you like to add another drink to the order, Y or N?: "
                )
                if option == 'y' or option == 'Y':
                    round_order = True
                    not_chosen_option = False
                elif option == 'n' or option == 'N':
                    round_order = False
                    not_chosen_option = False
                else:
                    print("\nSorry, I don't understand.")
                    not_chosen_option = True

        return order_dic
Exemplo n.º 5
0
 def choose_drink(self, drinks_dic):
     chosen_drink = True
     while chosen_drink:
         drink_table = table('DRINKS', drinks_dic)
         self.drink_tag = int(
             input("\nPlease select a drink using a number: "))
         if self.drink_tag not in drinks_dic.keys():
             print("\nThere are only so many drinks available, try again.")
             chosen_drink = True
             # potential check for number 0 input here.
         else:
             chosen_drink = False
     chosen_drink = True
     return self.drink_tag
Exemplo n.º 6
0
    def choose_name(self, people_dic, selected_name):
        chosen_name = True
        while chosen_name:
            name_table = table('PEOPLE', people_dic)
            self.name_tag = int(input("\nPlease choose a person: "))
            if self.name_tag not in people_dic.keys():
                print("\nThere are only so many people! Try again")
                chosen_name = True
            else:
                chosen_name = False

            person_name = people_dic[self.name_tag]

        chosen_name = True
        return self.name_tag
Exemplo n.º 7
0
def app_start():
    while True:
        os.system("clear")
        view_menu = True
        menu()  # show the menu
        # initial assignment of lists
        people = SL.LoadData().load_items('src/data/names.csv')
        drinks = SL.LoadData().load_items('src/data/drinks.csv')
        drinks_preferences = SL.LoadData().load_preferences(
            'src/data/new_preferences.csv')
        new_preference = AC.Preferences()
        people_dic = new_preference.data_dictionary(
            people)  # create people dictionary
        drinks_dic = new_preference.data_dictionary(
            drinks)  # create drinks dictionary

        while view_menu:  # Loop for decision making, accounting for mistakes
            try:
                option = int(input("\nChoose your selection here (1-10): ")
                             )  # user picks their desired page
                if option == 1:
                    if len(people) == 0:
                        print("\nThere are no people present, add some!")
                    else:
                        table('PEOPLE', people)
                    view_menu = False
                elif option == 2:
                    if len(drinks) == 0:
                        print("\nThere are no drinks, add some!")
                    else:
                        table('DRINKS', drinks)
                    view_menu = False
                elif option == 3:
                    new_people = AM.add_to_table('PEOPLE', people)
                    SL.SaveData().save_items('src/data/names.csv', new_people)
                    view_menu = False
                elif option == 4:
                    table('PEOPLE', people)
                    new_people = AM.remove_from_table('PEOPLE',
                                                      people_dic).values()
                    table('PEOPLE', new_people)
                    SL.SaveData().save_items("src/data/names.csv", new_people)
                    view_menu = False
                elif option == 5:
                    new_drinks = AM.add_to_table('DRINKS', drinks)
                    SL.SaveData().save_items('src/data/drinks.csv', new_drinks)
                    view_menu = False
                elif option == 6:
                    table('DRINKS', drinks)
                    new_drinks = AM.remove_from_table('DRINKS',
                                                      drinks_dic).values()
                    table('DRINKS', new_drinks)
                    SL.SaveData().save_items("src/data/drinks.csv", new_drinks)
                    view_menu = False
                elif option == 7:
                    drinks_prefs = AM.assign_preference(
                        people_dic, drinks_dic, people, drinks)
                    SL.SaveData().save_preferences(
                        'src/data/new_preferences.csv', drinks_prefs)
                    view_menu = False
                elif option == 8:
                    preferences_table = AM.preferences_display(
                        "PREFERENCES", drinks_preferences)
                    view_menu = False
                elif option == 9:
                    drinks_round = AC.Round(people, drinks)
                    beverages = drinks_round.order(people, drinks)
                    drinks_round.print_round(beverages)
                    view_menu = False
                elif option == 10:
                    print("\nThanks for stopping by, see you soon!\n")
                    exit()
                else:
                    print(
                        "\nSorry I dont understand.\nPlease choose between 1 and 10."
                    )
            except ValueError as v:  # Raised if anything other than an integer is input.
                print('\n')
                print(v)
                print("That is not an integer between 1 and 10, try again!")
            except NameError as n:  # Raised if the preferences list is opened without
                print('\n')  # assigning people to drinks
                print(n)

        if not view_another_page():  # Ending the app
            print("\nThanks for stopping by, see you soon!\n"
                  )  # FIX for 'if __name__ == "__main__"' clause!
            break
Exemplo n.º 8
0
def app_start():
    menu_initialisation()
    while True:
        AM.clear()    

        menu()                                                                      # show the menu
        # initial assignment of data dictionaries    
        people_dic = AM.Load_People()
        
        drinks_dic = AM.Load_Drinks()
        
        view_menu = True
        while view_menu:                                                            # Loop for decision making, accounting for mistakes
            try:    
                option = int(input("\nChoose your selection here (1-10): "))         # user picks their desired page
                if option == 1:
                    if len(people_dic.values()) == 0:
                        print("\nThere are no people present, add some!")
                    else:
                        table('PEOPLE', people_dic)  
                    view_menu = False
                elif option == 2:
                    if len(drinks_dic.values()) == 0:
                        print("\nThere are no drinks, add some!")
                    else:
                        table('DRINKS', drinks_dic) 
                    view_menu = False
                elif option == 3:
                    AM.add_person('PEOPLE')
                    AM.clear()
                    view_menu = False
                elif option == 4:
                    AM.remove_person('PEOPLE', people_dic)
                    
                    view_menu = False
                elif option == 5:
                    AM.add_drink('DRINKS')
                    AM.clear()
                    view_menu = False
                elif option == 6:
                    AM.remove_drink('DRINKS', drinks_dic)
                    
                    view_menu = False
                elif option == 7:
                    drinks_prefs = AM.assign_preference(people_dic, drinks_dic)
                    
                    view_menu = False
                elif option == 8: 
                    preferences_table = AM.access_preferences()
                    AM.display_preferences(preferences_table)   
                    view_menu = False
                elif option == 9:
                    drinks_round = AC.Round()
                    beverages = drinks_round.order(people_dic, drinks_dic)
                    drinks_round.print_round(beverages)
                    view_menu = False
                elif option == 10:
                    print("\nThanks for stopping by, see you soon!\n")
                    time.sleep(1)
                    print("""
                            *         *
                           ***       ***
                            *         *   
                    ***          **          ***
                     ***         **         ***
                      ****       **       ****
                        *****           *****
                          *****************
                            ************
                                *****
                    """)
                    time.sleep(2)
                    AM.clear()
                    exit()
                else: 
                    print("\nSorry I dont understand.\nPlease choose between 1 and 10.")
            except ValueError as v:                                                             # Raised if anything other than an integer is input.
                print('\n')
                print(v)
                print("That is not an integer between 1 and 10")
            except NameError as n:                                                              # Raised if the preferences list is opened without 
                print('\n')                                                                     # assigning people to drinks
                print(n)
                


        if not view_another_page():                                                             # Ending the app
            print("\nThanks for stopping by, see you soon!\n")
            time.sleep(1)
            print("""
                            *         *
                           ***       ***
                            *         *   
                    ***          **          ***
                     ***         **         ***
                      ****       **       ****
                        *****           *****
                          *****************
                            ************
                                *****
                    """)
            time.sleep(2)
            AM.clear()  
            break