我快被这个搞死了。。写了全部错全部。。。
各位可以帮帮我吗??Y.Y
这是问题 :
Writea programme to keep your friends telephone numbers.
You should be able to; a.
Add a new name and number b.
Look up a number given a name c.
Save the data to an object file whenyou terminate the programme d.
Restore the saved data when theprogram is rerun
这个是display的
- import java.util.*;
- class Menu {
- public static void main(String args[])throws Exception{
- int option;
- do {
-
- menu();
-
- option = getOption();
-
- processOption(option);
- }while (true);
- }
- private static void menu() {
- System.out.println("1->Add new number");
- System.out.println("2->Search new number");
- System.out.println("3->Exit");
- System.out.println("---------------------");
- }
- private static int getOption() throws Exception{
- int option;
- Scanner sc = new Scanner(System.in); System.out.print("Please enter an option: ");
- option = sc.nextInt(); return option;
- }
- private static void processOption(int o) throws Exception
- {
- switch(o){
-
- case 1:{
-
- System.out.println("You select one");
-
- break;
-
- }
-
- case 2: {
-
- System.out.println("You select two");
-
- break;
-
- }
-
- case 3: {
-
- System.out.println("Bye Bye");
-
- System.exit(0);
-
- }
-
- default:
-
- System.out.println("Invalid option!");
- }
-
- System.out.println("Press any key to continue");
-
- System.in.read();
- }}
复制代码 |