Java通讯录编程Word格式.docx

上传人:b****5 文档编号:21145527 上传时间:2023-01-27 格式:DOCX 页数:12 大小:16.70KB
下载 相关 举报
Java通讯录编程Word格式.docx_第1页
第1页 / 共12页
Java通讯录编程Word格式.docx_第2页
第2页 / 共12页
Java通讯录编程Word格式.docx_第3页
第3页 / 共12页
Java通讯录编程Word格式.docx_第4页
第4页 / 共12页
Java通讯录编程Word格式.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

Java通讯录编程Word格式.docx

《Java通讯录编程Word格式.docx》由会员分享,可在线阅读,更多相关《Java通讯录编程Word格式.docx(12页珍藏版)》请在冰豆网上搜索。

Java通讯录编程Word格式.docx

publicclassMailList

privateFriend[]list=newFriend[50];

publicMailList()

{}

//显示菜单

publicvoidAddressbook()

/*System.out.println("

+--------------------------------------+"

);

System.out.println("

+请根据菜单选择您的操作:

+"

+按1:

显示全部好友+"

+按2:

添加好友+"

+按3:

查找好友+"

+按4:

修改好友+"

+按5:

删除好友+"

+按6:

显示菜单+"

+按0:

退出程序+"

+作者:

*/

BufferedReaderbuf=newBufferedReader(newInputStreamReader(System.in));

请输入指令:

"

Strings;

intinstructions=-1;

try

{

s=buf.readLine();

instructions=Integer.parseInt(s);

}

catch(IOExceptione)

e.printStackTrace();

if(instructions>

6||instructions<

0)

System.out.println("

输入错误!

请根据菜单指令重新输入!

this.Addressbook();

if(instructions>

=0&

&

instructions<

=6)

switch(instructions)

{

case1:

//显示全部好友

intcount=0;

for(inti=0;

i<

list.length;

i++)

{

if(list[i]!

=null)

{

System.out.println(list[i].getName());

System.out.println(list[i].getTel());

count++;

}

}

System.out.println("

通讯录共有好友"

+count+"

人"

\n"

+"

this.Addressbook();

case2:

//添加好友信息

intindex=-1;

if(list[i]==null)

index=i;

break;

if(index==-1)

System.out.println("

通讯录已满,不能再添加好友!

return;

请输入好友信息"

姓名:

try

Stringname=buf.readLine();

电话:

Stringtel=buf.readLine();

list[index]=newFriend(name,tel);

添加成功!

catch(IOExceptione)

e.printStackTrace();

case3:

//查找好友

请输入要查找的好友姓名:

intm=0;

for(inti=0;

if(list[i]!

{

if(list[i].getName().equals(name))

{

System.out.println("

+list[i].getName());

+list[i].getTel());

m++;

}

}

if(m==0)

System.out.println("

查无此人!

}

case4:

//修改好友

请输入好友姓名:

try

for(inti=0;

是否要修改好友信息?

(y/n)"

Stringyn=buf.readLine();

if(yn.equals("

y"

))

{

System.out.println("

请选择要修改的信息.(name/tel)"

Stringnt=buf.readLine();

if(nt.equals("

name"

{

System.out.println("

请输入修改后的姓名。

Stringn=buf.readLine();

list[i].setName(n);

姓名修改成功!

修改后的信息:

是否要修改电话?

shi/fou"

Stringsf=buf.readLine();

if(sf.equals("

shi"

{

System.out.println("

请输入修改后的电话:

Stringt=buf.readLine();

list[i].setTel(t);

电话修改成功!

break;

}

elseif(sf.equals("

fou"

取消修改!

已退出该操作!

现在的信息如下:

else

已推出该操作!

}

elseif(nt.equals("

tel"

Stringt=buf.readLine();

list[i].setTel(t);

break;

else

}

elseif(yn.equals("

n"

{

break;

else

else

System.out.println("

break;

case5:

//删除好友

请输入要删除的好友姓名:

是否要删除该好友?

);

list[i]=null;

成功删除!

elseif(yn.equals("

取消删除!

查无此人!

//查找菜单

case6:

this.Addressbook();

case0:

System.exit(0);

//System.exit(0);

0--正常结束程序

//System.exit

(1);

1--异常关闭程序

}

过程三:

publicclassTest

publicstaticvoidmain(String[]args)

MailListm=newMailList();

m.Addressbook();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1