Dear my friends... First time I use Java, I feel as if I am in new world. I want after the user choose one of menu in main menu than the displayed is cleared (blanken) and come the aimed menu. Can I use another class for this implementation? I mean like modular programming. I make one file as the main menu (comadmin.class) and some other files to represent each of the options in the main menu (such as : customer.class, product.class,etc). How can I do that? Thanks in advance. ps : here is my simple code for the detail of my explanation. ================= public class comadmin { public static void main(String[] args) { int pilihmenu; System.out.println("========================================="); System.out.println("| Main Menu |"); System.out.println("========================================="); System.out.println("| Options : |"); System.out.println("| 1. Customer |"); System.out.println("| 2. Product Field |"); System.out.println("========================================="); pilihmenu = Keyin.inChar("Please choose (1-2) : "); switch (pilihmenu){ case '1' : System.out.println("Opening customer menu\n"); customer; break; case '2' : break; } } } __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/
Prabu Subroto wrote:
Dear my friends...
First time I use Java, I feel as if I am in new world.
I want after the user choose one of menu in main menu than the displayed is cleared (blanken) and come the aimed menu.
Can I use another class for this implementation? I mean like modular programming. I make one file as the main menu (comadmin.class) and some other files to represent each of the options in the main menu (such as : customer.class, product.class,etc).
How can I do that?
Thanks in advance.
ps : here is my simple code for the detail of my explanation. ================= public class comadmin { public static void main(String[] args) { int pilihmenu;
System.out.println("========================================="); System.out.println("| Main Menu |");
System.out.println("========================================="); System.out.println("| Options : |"); System.out.println("| 1. Customer |"); System.out.println("| 2. Product Field |");
System.out.println("========================================="); pilihmenu = Keyin.inChar("Please choose (1-2) : "); switch (pilihmenu){ case '1' : System.out.println("Opening customer menu\n"); customer; break; case '2' :
break; } }
}
You can use external or internal classes. It depends on how big this program will be and who will maintain it.
An example using internal classes: public class comadmin { public static void main(String[] args) { char pilihmenu; System.out.println("========================================="); // ... pilihmenu = Keyin.inChar("Please choose (1-2) : "); switch (pilihmenu){ case '1' : System.out.println("Opening customer menu\n"); (new customer()).start(); break; case '2' : System.out.println("Opening product menu\n"); (new product()).start(); } } static private class customer { //whatever.... public void start() { System.out.println("==========="); int menu = Keyin.inChar("customer: Please choose (1-2) : "); switch (menu){ case '1' : System.out.println("1 pressed"); break; } } } static private class product { //whatever.... public void start() { System.out.println("==========="); int menu = Keyin.inChar("product: Please choose (1-2) : "); switch (menu){ case '1' : System.out.println("1 pressed"); break; } } } } For the external classes just put the internal classes in other files and declare them as public , e.g. public class product.
participants (2)
-
expatriate
-
Prabu Subroto