Java怎么实现客户信息管理系统
发表于:2024-10-01 作者:千家信息网编辑
千家信息网最后更新 2024年10月01日,这篇文章主要讲解了"Java怎么实现客户信息管理系统",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Java怎么实现客户信息管理系统"吧!Custome
千家信息网最后更新 2024年10月01日Java怎么实现客户信息管理系统
这篇文章主要讲解了"Java怎么实现客户信息管理系统",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Java怎么实现客户信息管理系统"吧!
Customer类:
public class Customer { /** * @name 客户姓名 * @sex 性别 * @age 年龄 * @phone 电话号码 * @email 邮箱 */ private String name; private String sex; private int age; private String phone; private String email; public Customer(){}; public Customer(String name,String sex,int age,String phone,String email){ this.name=name; this.sex=sex; this.age=age; this.phone=phone; this.email=email; } public String getName(){ return this.name; } public void setName(String name){ this.name=name; } public String getSex(){ return this.sex; } public void setSex(String sex){ this.sex=sex; } public String getPhone(){ return phone; } public void setPhone(String phone){ this.phone=phone; } public int getAge(){ return this.age; } public void setAge(int age){ this.age=age; } public String getEmail(){ return this.email; } public void setEmail(String email){ this.email=email; }}
CustomerList 类:
public class CustomerList { private Customer [] customers; private static int total = 0; /** * 构造器初始化对象数组 * @param totalCustmoers 客户的总数 */ public CustomerList(int totalCustmoers){ customers = new Customer[totalCustmoers]; } /** * 增加客户 * @param customer 客户 * @return 返回是否添加成功 */ public boolean addCustomer(Customer customer){ if(customer!=null&&total=0 && index =0 && indexCustomerVIew类:
public class CustomerView { private CustomerList customerList = new CustomerList(10); /** * 显示主菜单 */ public void enterMainMenu(){ while(true) {System.out.println("-------------------客户信息管理软件-------------------"); System.out.println("1 "+"添加客户"); System.out.println("2 "+"修改客户"); System.out.println("3 "+"删除客户"); System.out.println("4 "+"客户列表"); System.out.println("5 "+"退 出"); System.out.println("-----------------------------------------------------"); Scanner input = new Scanner(System.in); int op = input.nextInt(); switch(op) { case 1 :this.addNewCustomer();break; case 2 :this.modifyCustomer();break; case 3 :this.deleteCustomer();break; case 4 :this.listAllCustomers();break; case 5 :System.exit(0);break; default: System.out.println("重新选择功能");break; } } } /** * 增加客户 */ private void addNewCustomer(){ /** * 从键盘处接收客户数据 */ System.out.println("-------------------添加客户-------------------"); Scanner input = new Scanner(System.in); System.out.println("姓名:"); String name = input.next(); System.out.println("性别:"); String sex=input.next(); System.out.println("年龄:"); int age = input.nextInt(); System.out.println("电话号码:"); String phone = input.next(); System.out.println("电子邮箱:"); String email = input.next(); /** * 对客户数据进行封装 */ Customer person = new Customer(name,sex,age,phone,email); Boolean flag=customerList.addCustomer(person); if(flag) { System.out.println("-------------------添加成功-------------------"); } else { System.out.println("-------------------添加失败-------------------"); } } /** * 修改客户信息 */ private void modifyCustomer(){ System.out.println("-------------------修改客户-------------------"); System.out.println("要修改的客户id:"); Scanner input = new Scanner(System.in); int number = input.nextInt(); Customer customer = customerList.getCustomer(number); System.out.println("姓名:"+customer.getName()); String name = CMUtility.readString(5,customer.getName()); System.out.println("性别:"+customer.getSex()); String sex = CMUtility.readString(5,customer.getSex()); System.out.print("年龄(" + customer.getAge() + "):"); int age = CMUtility.readInt(customer.getAge()); System.out.print("电话(" + customer.getPhone() + "):"); String phone = CMUtility.readString(13, customer.getPhone()); System.out.print("邮箱(" + customer.getEmail() + "):"); String email = CMUtility.readString(15, customer.getEmail()); /**得到新的客户数据*/ customer = new Customer(name,sex,age,phone,email); Boolean flag = customerList.replaceCustomer(number,customer); if(flag) { System.out.println("-------------------修改成功-------------------"); } else { System.out.println("-------------------修改失败-------------------"); } } /** * 删除客户 */ private void deleteCustomer(){ System.out.println("-------------------删除客户-------------------"); System.out.println("要删除的客户id:"); Scanner input = new Scanner(System.in); int number = input.nextInt(); while(true){ System.out.println("退出(-1)"); if(number>=0 && number工具类:
public class CMUtility { private static Scanner scanner = new Scanner(System.in); public static String readString(int limit) { return readKeyBoard(limit, false); } public static int readInt(int defaultValue) { int n; for (; ; ) { String str = readKeyBoard(2, true); if (str.equals("")) { return defaultValue; } try { n = Integer.parseInt(str); break; } catch (NumberFormatException e) { System.out.print("数字输入错误,请重新输入:"); } } return n; }
感谢各位的阅读,以上就是"Java怎么实现客户信息管理系统"的内容了,经过本文的学习后,相信大家对Java怎么实现客户信息管理系统这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
客户
信息
管理
成功
数据
管理系统
系统
姓名
年龄
性别
电话
邮箱
号码
数组
电话号码
学习
输入
内容
总数
电子
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
软件开发中的过度设计
nova8鸿蒙升级服务器过载
武汉网站建设服务器
医保显示服务器出错
我的世界国服怎么开启服务器
通联支付配套软件开发公司
南京创新网络技术代理价钱
湘潭软件开发培训价格
镇江软件开发公司挣钱吗
第三季度网络安全工作会议
斯诺登网络安全之道
华为认证网络安全认证
自世界银行数据库
服务器编程语言对比
服务器的配置参数在哪里看
互联网金融科技业务的发展模式
网络安全相关日志留存时间
it游戏软件开发制作
sim卡管理服务器
南威软件软件开发氛围
大连豪森软件开发有限公司简介
计算机网络技术专业招聘
石家庄软件开发薪资标准
华为认证网络安全认证
手机服务器lp地址怎么查
浪潮高密度服务器检测维修
小公司软件开发图片
云南曲靖网络安全工作会议
夏林聪网络安全
数据库 驱动层