IT 2033 Object Oriented Programming Menu-driven Application Development Budditha Hettige Department of Computer Science
IT 2033Object 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
27/11/2015 Budditha Hettige ([email protected])
Steps to Develop
• Create a menu (to select options)
• Create menu option input method
• Add menu to the application
7/11/2015 Budditha Hettige ([email protected]) 3
do
Menu
getOption
While()
Switch
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
Input Method
7/11/2015 Budditha Hettige ([email protected]) 7
• Can improve this method to avoid invalid input
– public static int getMenuOption(int Max)
Add New Employee
7/11/2015 Budditha Hettige ([email protected]) 9
Create new full time
Employee
Add new data from keyboard
Increase employee
count
Print All Employee Details
7/11/2015 Budditha Hettige ([email protected]) 10
F C M
3
Employee Count
Employee Array
Full time Employee
Contractor
Manager
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