classnoteimplementsSerializable{Stringname,phone,MobilePhone,zip,address,Email;publicvoidSetnote(Stringname,Stringphone,StringMobilePhone,Stringzip,Stringaddress,StringEm...
class note implements Serializable{
String name,phone,MobilePhone,zip,address,Email;
public void Setnote(String name,String phone,String MobilePhone,String zip,String address,String Email)
{
this.name=name;
this.phone=phone;
this.MobilePhone=MobilePhone;
this.zip=zip;
this.address=address;
this.Email=Email;
}
public void show()
{
System.out.println(name+" "+phone+" "+MobilePhone+" "+zip+" "+address+" "+Email+" ");
}
}
public class notebook{
public static void main(String args[])throws IOException
{
System.out.print("**************通讯录系统**************n");
System.out.print("1--------------显示通讯录信息!---------n"
+"2--------------查找记录! ---------n"
+"3-------------- 退出 ---------n");
System.out.print("请选择操作:");
String s;
int Cto;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
s=in.readLine();
Cto=Integer.parseInt(s);
while(Cto>3&&Cto<1){
System.out.print("选择错误的操作,请重新选择!");
s=in.readLine();
Cto=Integer.parseInt(s);
}
while(Cto>=1&&Cto<=3){
switch(Cto)
{
case 1:
下为显示记录的代码*********/
{
int i;
ArrayList Notelist=new ArrayList();
try{
ObjectInputStream infile=new ObjectInputStream(new FileInputStream("note.dat"));
Notelist=(ArrayList)infile.readObject();
infile.close();
}catch(Exception ex){}
if(Notelist.size()==0)
System.out.println("通讯录没有记录");
else
{
System.out.println("姓名"+" "+"固定电话"+" "+"手机 "+" "+"邮编 "+" "+"地址 "+" "+"电子邮件地址"+" ");
for(i=0;i
{
note Notebook=new note();
Notebook=(note)Notelist.get(i);
Notebook.show();
}
}
}
展开



