Menu-driven Application Development

IT 2033
Object Oriented Programming
Menu-driven Application Development
Budditha Hettige
Department of Computer Science
Menu driven Program
•
•
•
•
Common application type for the console window
Program run until user exit from it
User can select required options
Use Menu (number input) to select options
7/11/2015
Budditha Hettige ([email protected])
2
Steps to Develop
• Create a menu (to select options)
• Create menu option input method
• Add menu to the application
do
Menu
getOption
Switch
While()
7/11/2015
Budditha Hettige ([email protected])
3
Example
• Create a menu drive application to store Employee
details (class example). Your application should
support the following menu operations.
– 1. Add new employee (Full time , Contractor or Manager)
– 2. Print all employee details
– 3. Print given employee details
– 4. Exit
_
• Example available on:
– https://budditha.wordpress.com/object-oriented-programming-java/
7/11/2015
Budditha Hettige ([email protected])
4
Loop (Main)
7/11/2015
Budditha Hettige ([email protected])
5
Menu
Menu Options
7/11/2015
Budditha Hettige ([email protected])
6
Input Method
• Can improve this method to avoid invalid input
– public static int getMenuOption(int Max)
7/11/2015
Budditha Hettige ([email protected])
7
Main Method
Value to exit
7/11/2015
Budditha Hettige ([email protected])
8
Add New Employee
Create new full time
Employee
Add new data from keyboard
Increase employee
count
7/11/2015
Budditha Hettige ([email protected])
9
Print All Employee Details
Employee Count
3
Contractor
Employee Array
F
C
M
Full time Employee
7/11/2015
Manager
Budditha Hettige ([email protected])
10
Print given Employee Details
7/11/2015
Budditha Hettige ([email protected])
11
More on application development
•
•
•
•
•
Add error handling method(s) to avoid user errors
Complete the application
Build jar file (RUN →Clean and build project [Shift+F11])
Copy jar file into another location
Execute Jar file through the command
– Java –jar <jar_file_name>
7/11/2015
Budditha Hettige ([email protected])
12