资源描述:
《java实验报告——异常、集合类和泛型.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、成绩:面向对象原理与Java实践课程实验报告实验3:异常、集合类和泛型姓名____ 班级____ 学号____ 实验地点____ 实验时间____ 指导教师____ 一、实验目的:l掌握Java异常处理的应用l掌握Java中实现自定义异常l掌握泛型类的定义和应用l使用List接口及其实现类二、实验要求:l具备异常和泛型的概念知识(教材第5、7章内容)lJava异常处理的语法格式(教材第5章内容)l理解集合类和集合接口(教材第8章内容)l泛型类的定义(教材第7章内容)l编写程序完成以下实验内容并上交实验报告(包括电子文档与纸质文档)三、实验内
2、容:在实验1基础上实现异常处理,另外,记录的存储访问使用泛型化的List接口及其实现类进行。附实验1:设计并实现一个“广石化院电信学院学生通信录”系统。系统采用字符界面,在出现的主界面中按提示输入相应字符以选择“增加”、“删除”、“修改”、“查找”等功能进行操作(其中“查找”功能除能够查找某个学生的信息之外,还能够显示所有学生的信息)。四、设计思路:设计思路跟实验一的基本一致,只是将通讯记录的存储访问用List接口代替而已五、程序源代码:packagepkg_TXL;importjava.util.Scanner;publicclassZhuJieMi
3、an{/****该类为通讯录系统的主界面提供主要功能显示,以及负责主菜单与子菜单的正常跳转*/publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstub//XueShengXinXi[]Stu=ChuShiHua();//初始化系统数据XueShengXinXi[]Stu=newXueShengXinXi[100];Stu[0]=newXueShengXinXi("专业","班级","姓名","性别","电话","家庭住址");Stu[1]=newXueShengXinXi("自动
4、化","自动化10-1","张三","男","63256","fnhjfdhsdbh");Stu[2]=newXueShengXinXi("自动化","自动化10-2","李四","女","","nfhggdfddhsdbh");Stu[3]=newXueShengXinXi("电子","电子10-1","王五","男","6156","fnhvjbh");Stu[4]=newXueShengXinXi("电子","电子10-2","小红","女","63956","asdfnhjbh");Stu[5]=newXueShengXinXi("网络","网
5、络10-1","小明","男","656","nfgdgfnhjbh");Stu[6]=newXueShengXinXi("网络","网络10-2","小芳","女","62215","nfgdmmmdfhbdsh");Stu[7]=newXueShengXinXi("计算机","计算机10-1","黄龙","男","65584","bbbdddfnhjbh");Stu[8]=newXueShengXinXi("计算机","计算机10-2","陈玲","女","","mjgfddddfnhjbh");Stu[9]=newXueShengXinXi("测
6、控","测控10-1","赵小斌","男","","fthnrehbkjhjbh");Stu[10]=newXueShengXinXi("测控","测控10-2","钱颖","女","63641","dbfsvnnhjbh");Stu[11]=newXueShengXinXi("电信","电信10-1","孙武","男","","mmhmgvvdfnhjbh");Stu[12]=newXueShengXinXi("电信","电信10-2","李雨","女","6314","43ghffvvdfnhjbh");for(intx=13;x7、th;x++){Stu[x]=newXueShengXinXi();}System.out.println("欢迎使用广石化电信学院通讯录系统!");ZhuJieMian:for(intexit=0;exit==0;)//exit为退出主菜单的指示变量,0为不退出,非0为退出{System.out.println();System.out.println("************************************");System.out.println("****************主菜单****************");Sy
8、stem.out.print("1。查询学生信息tt");System.out.print