IT-209– Homework #05 – Manager Classes

Create one Python file that has the following:

1. UserInputManager class

2. DBManager class

3. main method

 

1 - Manager class: UserInputManager

 

ask_for_str 

-static 

-field (str) – the name of the item we are asking the user to enter

-The str that the user entered

-Ask the user for the field.

 

ask_for_int 

-static 

-field (str) – what we are asking the user to enter

-The VALID int the user entered

-Ask the user for the field. Validate that they entered valid int. Loop until valid.

 

ask_for_float

-static

-field (str) – what we are asking the user to enter

-The VALID float the user entered. Ask the user for the field. Validate that they entered valid float. Loop until valid.

 

 

2 - Manager class: DBManager

Note for all methods here: No input parameters. No return value.

 

__init__

instance

-Stub it out (print a message to indicate that this method was called)

 

display_main_menu

instance

-Display main menu options.

-Ensure user enters valid option.

-If invalid, display message and display menu again.

-If valid option, entered, all appropriate method. See main menu requirements below.

 

display_retrieve_menu

instance

-Display retrieve menu options. 

-Ensure user enters valid option.

-If invalid, display message and display menu again. 

-If valid option, entered, all appropriate method. See retrieve menu requirements below.

 

All methods needed to satisfy main menu and retrieve menu.

instance

Stub them out. See menu requirements below.

 

close_db

instance

-Stub it out

 

3 – main method that tests out the following methods:

-DBManager: constructor, display_menu, close_db

-InputManager: ask_for_str, ask_for_int, ask_for_float

-Test ALL menu / sub menu options to ensure correct method is called

 

Main Menu Sample Output:

Enter S to get started & create/refresh the table 

Enter C to create a new row

Enter R to retrieve data 

Enter U to update a row 

Enter D to delete a row 

Enter Q to quit the program

 

Enter choice:

 

Main Menu Requirements:

Menu Option                                               Method to Call

Enter S to get started & create/refresh the table       start

Enter C to create a new row                               create

Enter R to retrieve data                                       display_retrieve_menu

Enter U to update a row                                       update

Enter D to delete a row                                       delete

Enter Q to quit the program No method call,               quit the loop

 

Retrieve Menu Sample Output:

Enter K to retrieve one row based on key 

Enter A to retrieve all rows

Enter Q to quit this sub menu Enter         

choice: 

 

Retrieve Menu Requirements

Menu Option                                           Method to Call

Enter K to retrieve one row based on key           retrieve_one

Enter A to retrieve all rows                                   retrieve_all

Enter Q to quit the program No method call,          quit the loop

 

Note for both Menus – If user enters invalid option, display message and loop to show menu again. Example:

 

Enter K to retrieve one row based on key 

Enter A to retrieve all rows

Enter Q to quit this sub menu

 

Enter choice: X

You have entered an invalid menu option. Try again.

 

Enter K to retrieve one row based on key 

Enter A to retrieve all rows

Enter Q to quit this sub menu

 

Need a custom answer at your budget?

This assignment has been answered 5 times in private sessions.

© 2020 Codify Tutor. All rights reserved