def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_of_customers = crm.get_data_to_list() # your code options = [ "Add new record", "Remove a record", "Update record", "Id of the customer with the longest name", "Customers has subscribed to the newsletter", "Print table" ] title_list = ["ID", "Name", "e-mail", "subscribed"] choice = None while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs( ["Name: ", "e-mail: ", "subscribed: "], "Please enter value: ") new_record.insert(0, crm.get_random_id(list_of_customers)) list_of_customers = crm.add(list_of_customers, new_record) elif choice == "2": # id_of_record_to_remove = id_to_number_of_line(list_of_customers) id_of_record_to_remove = ask_untill_correct(list_of_customers) list_of_customers = crm.remove( list_of_customers, common.check_id_by_number(list_of_customers, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct(list_of_customers) updated_record = terminal_view.get_inputs( ["Name: ", "e-mail: ", "subscribed: "], "Please enter value: ") list_of_customers = crm.update( list_of_customers, common.check_id_by_number(list_of_customers, int(id_of_record_to_update)), updated_record) elif choice == "4": terminal_view.print_result( crm.get_longest_name_id(list_of_customers), "Longest person's ID") elif choice == "5": terminal_view.print_result( crm.get_subscribed_emails(list_of_customers), "List of subsrcibe user") elif choice == "6": terminal_view.print_table(list_of_customers, title_list) elif choice == "0": crm.export_list_to_file(list_of_customers) else: terminal_view.print_error_message( "There is no such choice.") # your code
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_of_inventory = inventory.get_data_to_list() # your code options = ["Add new record", "Remove a record", "Update record", "Display available items", "Get average durability by manufacturers", "Print Table"] title_list = ["ID", "CONSOLA", "PRODUCENT", "YEAR", "DURABILITY"] choice = None while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ") new_record.insert(0, inventory.get_random_id(list_of_inventory)) list_of_inventory = inventory.add(list_of_inventory, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct(list_of_inventory) list_of_inventory = inventory.remove(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct(list_of_inventory) updated_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ") list_of_inventory = inventory.update(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_update)), updated_record) elif choice == "4": available_items = inventory.get_available_items(list_of_inventory) terminal_view.print_result(available_items, "Available items") elif choice == "5": average_durability = inventory.get_average_durability_by_manufacturers(list_of_inventory) terminal_view.print_result(average_durability, "Average durability by manufacturers") elif choice == "6": terminal_view.print_table(list_of_inventory, title_list) elif choice == "0": inventory.export_list_to_file(list_of_inventory) else: terminal_view.print_error_message("There is no such choice.")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ MAX_YEAR = 2020 list_of_accounting = accounting.get_data_to_list() # your code options = [ "Add new record", "Remove a record", "Update record", "Which year has the highest profit?", "What is the average per item", "Print table" ] title_list = ["ID", "Month", "Day", "Year", "Type", "Amount"] choice = None while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs( ["Month: ", "Day: ", "Year: ", "Type: ", "Amount: "], "Please enter value: ") new_record.insert(0, accounting.get_random_id(list_of_accounting)) list_of_accounting = accounting.add(list_of_accounting, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct( ["Please insert ID"], len(list_of_accounting)) list_of_accounting = accounting.remove( list_of_accounting, common.check_id_by_number(list_of_accounting, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct( ["Please insert ID"], len(list_of_accounting)) updated_record = terminal_view.get_inputs( ["Month: ", "Day: ", "Year: ", "Type: ", "Amount :"], "Please enter value: ") list_of_accounting = accounting.update( list_of_accounting, common.check_id_by_number(list_of_accounting, int(id_of_record_to_update)), updated_record) elif choice == "4": result = accounting.which_year_max(list_of_accounting) terminal_view.print_result(str(result), "Year of the highest profile ") elif choice == "5": year_of_check = ask_untill_correct(["Year of publishing: "], MAX_YEAR) result = accounting.avg_amount(list_of_accounting, year_of_check) terminal_view.print_result(str(result), "Avernage items by year") elif choice == "6": terminal_view.print_table(list_of_accounting, title_list) elif choice == "0": accounting.export_list_to_file(list_of_accounting) else: terminal_view.print_error_message( "There is no such choice.") # your code
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_of_games = sales.get_data_to_list() # your code options = [ "Add new record", "Remove a record", "Update record", "Id of the item that was sold for the lowest price", "Items are sold between two given dates", "Print table" ] choice = None title_list = ["ID", "TITLE", "SALES", "MONTH", "DAY", "YEAR"] while choice != "0": # terminal_view.print_table(table, title_list choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs( ["Title: ", "Price: ", "Month: ", "Day: ", "Year: "], "Please enter value: ") new_record.insert(0, sales.get_random_id(list_of_games)) list_of_games = sales.add(list_of_games, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct(list_of_games) list_of_games = sales.remove( list_of_games, common.check_id_by_number(list_of_games, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct(list_of_games) updated_record = terminal_view.get_inputs( ["Title: ", "Price: ", "Month: ", "Day: ", "Year: "], "Please enter value: ") list_of_games = sales.update( list_of_games, common.check_id_by_number(list_of_games, int(id_of_record_to_update)), updated_record) elif choice == "4": label = "What is the id of the item that was sold for the lowest price?" result = str(sales.get_lowest_price_item_id(list_of_games)) terminal_view.print_result(result, label) elif choice == "5": label = "Which items are sold between two given dates? (from_date < sale_date < to_date)" month_from = terminal_view.get_inputs( ['Month from'], "Please give starting month.") day_from = terminal_view.get_inputs(['Day from'], "Please give starting day.") year_from = terminal_view.get_inputs(['Year from'], "Please give starting year.") month_to = terminal_view.get_inputs(['Month to'], "Please give ending month.") day_to = terminal_view.get_inputs(['Day to'], "Please give ending day.") year_to = terminal_view.get_inputs(['Year to'], "Please give ending year.") month_from = int(month_from[0]) day_from = int(day_from[0]) year_from = int(year_from[0]) month_to = int(month_to[0]) day_to = int(day_to[0]) year_to = int(year_to[0]) result = (sales.get_items_sold_between(list_of_games, month_from, day_from, year_from, month_to, day_to, year_to)) terminal_view.print_result(result, label) elif choice == "6": terminal_view.print_table(list_of_games, title_list) elif choice == "0": sales.export_list_to_file(list_of_games) else: terminal_view.print_error_message("There is no such choice.") #
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_of_humans = hr.get_data_to_list() # your code options = [ "Add new record", "Remove a record", "Update record", "Search oldest persons", "Search persons closest to average", "Print table" ] title_list = ["ID", "NAME", "YEAR"] choice = None while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs(["Name: ", "Birthyear: "], "Please enter value: ") new_record.insert(0, hr.get_random_id(list_of_humans)) list_of_humans = hr.add(list_of_humans, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct(list_of_humans) list_of_humans = hr.remove( list_of_humans, common.check_id_by_number(list_of_humans, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct(list_of_humans) updated_record = terminal_view.get_inputs( ["Name: ", "Birthyear: "], "Please enter value: ") list_of_humans = hr.update( list_of_humans, common.check_id_by_number(list_of_humans, int(id_of_record_to_update)), updated_record) elif choice == "4": oldest_persons = hr.get_oldest_person(list_of_humans) terminal_view.print_result(oldest_persons, "List of oldest persons") elif choice == "5": closest_persons_to_avg = hr.get_persons_closest_to_average( list_of_humans) terminal_view.print_result( closest_persons_to_avg, "List of persons closest to average year") elif choice == "6": terminal_view.print_table(list_of_humans, title_list) elif choice == "0": hr.export_list_to_file(list_of_humans) else: terminal_view.print_error_message("There is no such choice.")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_of_games = store.get_data_to_list() # your code options = [ "Add new record", "Remove a record", "Update record", "Count games each manufacturer", "Average of games", "Print table" ] choice = None title_list = ["ID", "TITLE", "MANUFACTURER", "PRICE", "IN STOCK"] while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs( ["Title: ", "Manufacturer: ", "Price: ", "In stock: "], "Please enter value: ") new_record.insert(0, store.get_random_id(list_of_games)) list_of_games = store.add(list_of_games, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct(list_of_games) list_of_games = store.remove( list_of_games, common.check_id_by_number(list_of_games, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct(list_of_games) updated_record = terminal_view.get_inputs( ["Title: ", "Manufacturer: ", "Price: ", "In stock: "], "Please enter value: ") list_of_games = store.update( list_of_games, common.check_id_by_number(list_of_games, int(id_of_record_to_update)), updated_record) elif choice == "4": label = "The kinds of game that are available of each manufacturer: " result = store.get_counts_by_manufacturers(list_of_games) terminal_view.print_result(result, label) elif choice == "5": manufacturer = terminal_view.get_inputs( ['Manufacturer : '], 'Please select a manufacturer :') manufacturer = manufacturer[0] result = str( store.get_average_by_manufacturer(list_of_games, manufacturer)) label = "The average amount of games in stock of {} ".format( manufacturer) terminal_view.print_result(result, label) elif choice == '6': terminal_view.print_table(list_of_games, title_list) elif choice == "0": store.export_list_to_file(list_of_games) else: terminal_view.print_error_message("There is no such choice.")