i have write this layout but dunno how to write this 3 function in serializable...can u all help me? Y.Y
this was the question:
Write a 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 when you terminate the programme
d. Restore the saved data when the program is rerun
the layout:
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();
}
}