After the user interface tools are created and tested, we are going to build the main skeleton of our application. This application will be a menu driven program and will work as follows:
1- When the program starts the title of the application is displayed.
2- Then a menu is displayed. 3- The user selects one of the options on the Menu. 4- Depending on the selection, the corresponding action will take place. 5- The Application will pause to attract the user s attention 6- If the option selected is not Exit program, then the program will go back to option 2 7- If the option selected is Exit program, the program ends.
The above is essentially the pseudo code for any program that uses a menu driven user interface.
To accomplish the above create the following three functions:
Receives a single character from the user and then clears the keyboard (flushKeyboard()). If the character read is anything other than “Y”, “y”, “N” or “n”, it will print an error message as follows: >Only (Y)es or (N)o are acceptable: < and goes back to read a character until one of the above four characters is received. Then, it will return 1 if the entered character is either “y” or “Y”, otherwise it will return 0.
Menu prints the following options:>< >1- List all items< >2- Search by SKU< >3- Checkout an item< >4- Stock an item< >5- Add new item or update item< >6- Delete item< >7- Search by name< >0- Exit program< >> < Then, it receives an integer between 0 and 7 inclusive and returns it. Menu will not accept any number less than 0 or greater than 7 (Use the proper UI function written in the UI tools).
This function is the heart of your application and will run the whole program.
GroceryInventorySystem, first, displays the welcome message and skips a line and then displays the menu and receives the user s selection.
If user selects 1, it displays: >List Items under construction!< and goes to newline
If user selects 2, it displays: >Search Items under construction!< and goes to newline
If user selects 3, it displays: >Checkout Item under construction!< and goes to newline
If user selects 4, it displays: >Stock Item under construction!< and goes to newline
If user selects 5, it displays: >Add/Update Item under construction!< and goes to newline
If user selects 6, it displays: >Delete Item under construction!< and goes to newline
If user selects 7, it displays: >Search by name under construction!< and goes to newline
After receiving a number between 1 and 7, it will pause the application and goes back to display the menu.
If user selects 0, it displays: >Exit the program? (Y)es/(N)o): < and waits for the user to enter “Y”, ”y”, “N” or “n” for Yes or No. If the user replies Yes, it will end the program, otherwise it goes back to display the menu.
The following is a general pseudo code for a menu driven user interface. Using this pseudo code is optional. You can use any other logic if you like.
Application user interface pseudo code:
while it is not done display menu get selected option from user check selection: option one selected act accordingly end option one option two selected act accordingly
end option two . . . . Exit is selected program is done end exit end check end while