java课程设计客户管理系统源代码.docx
《java课程设计客户管理系统源代码.docx》由会员分享,可在线阅读,更多相关《java课程设计客户管理系统源代码.docx(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、java课程设计客户管理系统源代码 完整代码: 1.客户类(classperson): package客户管理系统; publicclass Person privateint num; private String name; private String address; private String sex; public Person() public Person(int num,String name,String address,String sex) this.num=num; =name; this.address=address; this.sex=sex; publicv
2、oid setNum(int num) this.num=num; publicint getNum() return num; publicvoid setName(String name) =name; public StringgetName() return name; publicvoid setAddress(String address) this.address=address; public StringgetAddress() return address; publicvoid setSex(String sex) this.sex=sex; public Stringg
3、etSex() return sex; public StringtoString() returnt+num+t+name+t+address+t+sex; 2.菜单类(classMenu): package客户管理系统; import publicclass Menu Scanner input=new Scanner(System.in); public Menu() publicint showMenu() System.out.println(*); System.out.println(客户管理系统); System.out.println(=); System.out.print
4、ln(增加); System.out.println(删除); System.out.println(修改); System.out.println(查询); System.out.println(浏览); System.out.println(退出); System.out.println(*); System.out.print(请选择操作:); return input.nextInt(); publicint subMenu() System.out.println(t); System.out.println(t1按客户编号查询); System.out.println(t2按客户姓
5、名查询); System.out.println(t3按地址查询); System.out.println(t4退出); System.out.println(t请选择查询编号); return input.nextInt(); 3.实际操作类(classFileOperate):package客户管理系统; import import import import import import import import import java.util.Scanner; publicclass FileOperate privatestatic String INFO=D:/info.dat;
6、 File file=new File(INFO); Scanner input=new Scanner(System.in); public FileOperate() if(!file.exists() try file.createNewFile(); catch(IOException e) e.printStackTrace(); public ListgetList()throws NumberFormatException,IOException BufferedReader br=new BufferedReader(new FileReader(file); String m
7、sg=null; Listlist=new ArrayList(); while(msg=br.readLine()!=null) String arr=msg.split(t); int num=Integer.parseInt(arr0); String name=arr1; String address=arr2; String sex=arr3; Person person=new Person(num,name,address,sex); list.add(person); br.close(); return list; privatevoid savelist(Listlist)
8、throws FileNotFoundExceptio n PrintWriter pw=new PrintWriter(new File(INFO); for(Person c:list) pw.format(%dt%st%st%strn,c.getNum(),c.getName(),c.getAd dress(),c.getSex(); pw.close(); publicint getper(int num)throws NumberFormatException,IOException Listlist=getList(); for(int i=0;i Person per=list.
9、get(i); if(num=per.getNum() return i; return-1; /增加 publicvoid insert()throws NumberFormatException,IOException System.out.println(请输入编号:); int num=input.nextInt(); int index=getper(num); if(index!=-1) System.out.println(此编号已存在!); else System.out.println(请输入姓名:); String name=input.next(); System.out
10、.println(请输入地址:); String address=input.next(); System.out.println(请输入性别:); String sex=input.next(); Person person=new Person(num,name,address,sex); Listlist=getList(); list.add(person); savelist(list); System.out.println(新增成功!); /删除 publicvoid delete()throws NumberFormatException,IOException System.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 课程设计 客户 管理 系统 源代码
限制150内