def student_menu(student): print(student.get_full_name()) user_choice = '' while user_choice != 0: view.print_student_menu() user_choice = view.get_user_input() if user_choice == 1: show_grades(student) elif user_choice == 2: grade = view.get_user_input() student.add_grade(grade)
def main_menu(): school = School.create_from_csv('school.csv') user_choice = None while user_choice != 0: view.print_main_menu() user_choice = view.get_user_input() if user_choice == 1: view.get_list(school.get_all_teachers()) elif user_choice == 2: print(school.get_best_class()) elif user_choice == 3: choose_class(school) elif user_choice == 4: new_class = add_class(school) class_controller.class_menu(new_class) elif user_choice == 5: school.save_to_file() view.print_exit_message()
def remove_owner(flat): show_owners() user_choice = view.get_user_input() if int(user_choice) in range(len(flat.list_of_owners)): owner = flat.owners[user_choice - 1] flat.remove_owner(owner) else: view.print_error_message()
def find_flat_by_number(block): number = view.get_user_input() flat = block.find_flat(number) if flat: flat_controller.flat_menu(flat) else: view.print_error_message()
def get_user_input(action): amt = None acct_num = None vendor_id = None valid_input = True if 'amount' in action: amt = view.get_user_input('Enter amount:', 5) if not is_number(amt, 'float'): view.show_user_results('Charge amount must be a valid number') valid_input = False else: if float(amt) < 0: view.show_user_results('Amount must be a positive number') valid_input = False if 'account' in action: acct_num = view.get_user_input('Enter account number:', 5) if not is_number(acct_num, 'int'): view.show_user_results('Account number must be a valid integer') valid_input = False else: if int(acct_num) < 0: view.show_user_results('Account number must be a positive integer') valid_input = False if 'vendor' in action: vendor_id = view.get_user_input('Enter vendor id:', 5) if not is_number(vendor_id, 'int'): view.show_user_results('Vendor id must be a valid integer') valid_input = False else: if int(vendor_id) < 0: view.show_user_results('Vendor id must be a positive integer') valid_input = False r_amt = float(amt) if valid_input and amt is not None else None r_acct = int(acct_num) if valid_input and acct_num is not None else None r_vendor = int(vendor_id) if valid_input and vendor_id is not None else None return r_amt, r_acct, r_vendor, valid_input
def block_menu(block): print(block.get_address_of_block()) user_choice = '' while user_choice != '0': view.print_block_menu() user_choice = view.get_user_input() if user_choice == '1': block.get_all_flats() elif user_choice == '2': find_flat_by_number(block) elif user_choice == '3': print('to do:P')
def flat_menu(flat): print(flat.get_info_about_flat()) user_choice = '' while user_choice != '0': view.print_flat_menu() user_choice = view.get_user_input() if user_choice == '1': show_owners(flat) elif user_choice == '2': add_owner(flat) elif user_choice == '3': remove_owner(flat)
def play(self): view.new_game_message() # Draw the lines and starting pieces on the board. self.board.create() # Loop until a player quits or the game ends. while 1: color = self.state.get_whose_turn() # If color is None, the game logic could not find a legal move. if not color: self.game_over() # Allow the user to play another game. return view.get_play_again() # Get the player's move. action = view.get_user_input(color) if action == 'quit': # Though the user quit the game, allow him to start a new one. return view.get_play_again() self.make_move(action[0], action[1])
def class_menu(school_class): user_choice = '' while user_choice != 0: view.print_class_menu() user_choice = view.get_user_input() if user_choice == 1: print(school_class.get_best_student()) elif user_choice == 2: print(school_class.get_average_grade()) elif user_choice == 3: view.get_list(school_class.get_class_subjects()) elif user_choice == 4: add_teacher(school_class) elif user_choice == 5: remove_teacher(school_class) elif user_choice == 6: add_student(school_class) elif user_choice == 7: remove_student(school_class) elif user_choice == 8: show_all_students(school_class) elif user_choice == 9: show_teachers(school_class) elif user_choice == 10: choose_student(school_class) elif user_choice == 11: # choose teacher pass
def main_menu(): todo_list = ToDoList.create_from_csv('todo_items.csv') user_choice = '' while user_choice != 0: view.print_main_menu() user_choice = view.get_user_input() if user_choice == 1: show_all_items(todo_list) elif user_choice == 2: add_new_item(todo_list) elif user_choice == 3: mark_item(todo_list) elif user_choice == 4: todo_list.archive() todo_list.save_data_to_file('todo_items.csv') view.print_exit_message()
def main_menu(): csv_path = 'community.csv' community = Community.create_from_csv(csv_path) view.welcome_screen(community.name) user_choice = '' while user_choice != '0': view.print_main_menu() user_choice = view.get_user_input() if user_choice == '1': Community.get_all_blocks() elif user_choice == '2': choose_block() elif user_choice == '3': add_new_block(community) elif user_choice == '4': # TODO find address by owner pass view.print_exit_message()
def choose_student(school_class): show_all_students(school_class) user_choice = view.get_user_input() if user_choice in range(len(school_class.students)): student = school_class.sort_students()[user_choice] student_controller.student_menu(student)
def remove_student(school_class): show_all_students(school_class) user_choice = view.get_user_input() school_class.remove_student(user_choice)
def remove_teacher(school_class): show_teachers() user_choice = view.get_user_input() school_class.remove_teacher(user_choice)
def search_available_by_artist(): artist_name = view.get_user_input( 'What\'s the name of the artist you want to search for?') artworks = artworkDB.search_available_by_artist(artist_name) view.show_artwork_info(artworks)
def add_artwork(): artist = view.get_user_input('What\'s the artist\'s name?') artwork_name = view.get_user_input('What is the new artwork called?') price = view.get_decimal_input('What is the price of the artwork?') availability = view.get_user_input('Is this item available? (Y/N)') artworkDB.add_artwork(artist, artwork_name, price, availability)
def delete_artwork(): artwork_name = view.get_user_input( 'What\'s the name of the artwork you want to delete?') artworkDB.delete_artwork(artwork_name)
def change_availability(): artwork_name = view.get_user_input( 'What artwork would you like to change the availability for?') availability = view.get_user_input('Is this available? (Y/N)') artworkDB.change_availability(artwork_name, availability)
def mark_item(todo_list): show_all_items(todo_list) user_choice = view.get_user_input() if user_choice in range(len(todo_list.list_of_items) + 1): todo_list.mark_item(user_choice - 1)
def add_artist(): artist_name = view.get_user_input('What\'s the name of the new artist?') artist_email = view.get_user_input('What\'s the artist\'s email address?') print(artworkDB.add_artist(artist_name, artist_email))