资源分享:

尚硅谷

链接:https://pan.baidu.com/s/1B_liAbYxos9voDuFLx-Ldg 
提取码:1if5 
--来自百度网盘超级会员V6的分享

「Project2(客户信息管理软件)」https://www.aliyundrive.com/s/y1SmwiNFcYH 提取码: c6x9 点击链接保存,或者复制本段内容,打开「阿里云盘」APP ,无需下载极速在线查看,视频原画倍速播放。

我实现的:

「myproject2」https://www.aliyundrive.com/s/N4Eb5hZchpu 提取码: c6x9 点击链接保存,或者复制本段内容,打开「阿里云盘」APP ,无需下载极速在线查看,视频原画倍速播放。

1.需求说明

每个客户的信息被保存在Customer对象中。 以一个Customer类型的数组来记录当前所有的客户。 每次“添加客户”(菜单1)后,客户(Customer)对象被添加到数组中。 每次“修改客户”(菜单2)后,修改后的客户(Customer)对象替换数组中原对象。 每次“删除客户”(菜单3)后,客户(Customer)对象被从数组中清除。 执行“客户列表 ”(菜单4)时,将列出数组中所有客户的信息。

2.软件设计结构

CustomerView为主模块,负责菜单的显示和处理用户操作 CustomerList为Customer对象的管理模块,内部用数组管理一组Customer对象,并提供相应的添加、修改、删除和遍历方法,供CustomerView调用 Customer为实体对象,用来封装客户信息

3.enterMainMenu()方法的活动图

4. 代码实现

首先,项目的结构如图所示:

Customer类的代码:

package p2.bean;/*** @author: admin* @date: 2022/4/4 14:30* @description:Customer为实体对象,原来封装客户信息*/public class Customer {private String name;private char gender;private int age;private String phone;private String email;public String getName() {return name;}public void setName(String name) {this.name = name;}public char getGender() {return gender;}public void setGender(char gender) {this.gender = gender;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}//无参构造器public Customer() {}public Customer(String name, char gender, int age) {this(name, gender, age, "", "");}//全参构造器public Customer(String name, char gender, int age, String phone, String email) {this.name = name;this.gender = gender;this.age = age;this.phone = phone;this.email = email;}//方法public String getDetails() {return name + "\t" + gender + "\t" + age + "\t\t" + phone + "\t" + email;}
}

CustomerList类的代码:

package p2.service;import p2.bean.Customer;/*** @BelongsProject: myproject2* @BelongsPackage: p2.service* @Classname: CustomerList* @Author: admin* @Date: 2022/4/4 14:26* @Description:内部封装一个Customer[],提供对Customer数据的增删改查操作*/
public class CustomerList {private Customer[] customers;private int total;//记录存储的客户的个数/*** @author: admin* @date: 2022/4/4 14:36* @description:用来初始化customers数组的构造器* @Param totalCustomer: 指定数组的长度* @return: null*/public CustomerList(int totalCustomer){customers = new Customer[totalCustomer];}/*** @author: admin* @date: 2022/4/4 14:37* @description:添加指定的客户到数组中* @Param customer:* @return: boolean     true:添加成功 false:添加失败*/public boolean addCustomer(Customer customer){if (total>=customers.length){return false;}customers[total++] = customer;return true;}/*** @author: admin* @date: 2022/4/4 14:41* @description:替换指定索引位置上的数组元素* @Param index: * @Param cust:  * @return: boolean     true:添加成功 false:添加失败*/public boolean replaceCustomer(int index, Customer cust){if (index>=0 && index < total){customers[index] = cust;return true;}return false;}/*** @author: admin* @date: 2022/4/4 14:47* @description:删除指定索引位置上的元素* @Param index:* @return: boolean*/public boolean deleteCustomer(int index){if (index >=0 && index<total){for (int i=index;i<total-1;i++){customers[i] = customers[i+1];}
//          customers[total - 1] = null;
//          total--;//存储的总人数减少1.customers[--total] = null;return true;}return false;}/*** @author: admin* @date: 2022/4/4 14:49* @description: 获取所有的customers对象构成的数组* @return: p2.bean.Customer[]*/public Customer[] getAllCustomers(){Customer[] custs = new Customer[total];//给数组元素赋值for (int i=0;i<custs.length;i++){custs[i] = customers[i];}return custs;}/*** @author: admin* @date: 2022/4/4 14:51* @description:返回指定索引位置上的Customer* @Param index:* @return: p2.bean.Customer*/public Customer getCustomer(int index){if(index >= 0 && index < total){return customers[index];}return null;}/*** @author: admin* @date: 2022/4/4 14:51* @description: 返回Customer对象的个数* @return: int*/public int getTotal(){
//        return customers.length;//错误的return total;}}

CustomerView类的代码:

package p2.ui;import p2.service.CustomerList;
import p2.util.CMUtility;
import p2.bean.Customer;
/*** @BelongsProject: myproject2* @BelongsPackage: p2.ui* @Classname: CustomerView* @Author: admin* @Date: 2022/4/4 14:28* @Description:*/
public class CustomerView {private CustomerList customers = new CustomerList(10);//    public CustomerView() {
//        Customer cust = new Customer("张三", '男', 30, "010-56253825",
//                "abc@email.com");
//        customers.addCustomer(cust);
//    }/*** @author: admin* @date: 2022/4/4 15:01* @description: 显示主菜单,响应用户输入* 根据用户操作分别调用其他相应的成员方法(如addNewCustomer),以完成客户信息处理。* @return: void*/public void enterMainMenu(){boolean loopFlag = true;do {System.out.println("\n-----------------客户信息管理软件-----------------\n");System.out.println("                   1 添 加 客 户");System.out.println("                   2 修 改 客 户");System.out.println("                   3 删 除 客 户");System.out.println("                   4 客 户 列 表");System.out.println("                   5 退       出\n");System.out.print("                   请选择(1-5):");char key = CMUtility.readMenuSelection();System.out.println();switch (key) {case '1':addNewCustomer();break;case '2':modifyCustomer();break;case '3':deleteCustomer();break;case '4':listAllCustomers();break;case '5':System.out.print("确认是否退出(Y/N):");char yn = CMUtility.readConfirmSelection();if (yn == 'Y')loopFlag = false;break;}} while (loopFlag);}/*** @author: admin* @date: 2022/4/4 15:01* @description: 添加客户* @return: void*/private void addNewCustomer(){System.out.println("---------------------添加客户---------------------");System.out.print("姓名:");String name = CMUtility.readString(4);System.out.print("性别:");char gender = CMUtility.readChar();System.out.print("年龄:");int age = CMUtility.readInt();System.out.print("电话:");String phone = CMUtility.readString(15);System.out.print("邮箱:");String email = CMUtility.readString(15);//将上述数据封装到对像当中Customer cust = new Customer(name, gender, age, phone, email);boolean flag = customers.addCustomer(cust);if (flag) {System.out.println("---------------------添加完成---------------------");} else {System.out.println("----------------记录已满,无法添加-----------------");}}/*** @author: admin* @date: 2022/4/4 15:01* @description: 修改客户* @return: void*/private void modifyCustomer(){System.out.println("---------------------修改客户---------------------");int index = 0;Customer cust = null;for (;;) {System.out.print("请选择待修改客户编号(-1退出):");index = CMUtility.readInt();if (index == -1) {return;}cust = customers.getCustomer(index - 1);if (cust == null) {System.out.println("无法找到指定客户!");} elsebreak;}System.out.print("姓名(" + cust.getName() + "):");String name = CMUtility.readString(4, cust.getName());System.out.print("性别(" + cust.getGender() + "):");char gender = CMUtility.readChar(cust.getGender());System.out.print("年龄(" + cust.getAge() + "):");int age = CMUtility.readInt(cust.getAge());System.out.print("电话(" + cust.getPhone() + "):");String phone = CMUtility.readString(15, cust.getPhone());System.out.print("邮箱(" + cust.getEmail() + "):");String email = CMUtility.readString(15, cust.getEmail());cust = new Customer(name, gender, age, phone, email);boolean flag = customers.replaceCustomer(index - 1, cust);if (flag) {System.out.println("---------------------修改完成---------------------");} else {System.out.println("----------无法找到指定客户,修改失败--------------");}}/*** @author: admin* @date: 2022/4/4 15:02* @description: 删除客户* @return: void*/private void deleteCustomer(){System.out.println("---------------------删除客户---------------------");int index = 0;Customer cust = null;for (;;) {System.out.print("请选择待删除客户编号(-1退出):");index = CMUtility.readInt();if (index == -1) {return;}cust = customers.getCustomer(index - 1);if (cust == null) {System.out.println("无法找到指定客户!");} elsebreak;}System.out.print("确认是否删除(Y/N):");char yn = CMUtility.readConfirmSelection();if (yn == 'N')return;boolean flag = customers.deleteCustomer(index - 1);if (flag) {System.out.println("---------------------删除完成---------------------");} else {System.out.println("----------无法找到指定客户,删除失败--------------");}}/*** @author: admin* @date: 2022/4/4 15:02* @description:客户列表* @return: void*/private void listAllCustomers(){System.out.println("---------------------------客户列表---------------------------");Customer[] custs = customers.getAllCustomers();if (custs.length == 0) {System.out.println("没有客户记录!");} else {System.out.println("编号\t姓名\t性别\t年龄\t电话\t\t邮箱");for (int i = 0; i < custs.length; i++) {System.out.println(i + 1 + "\t\t" + custs[i].getName() + "\t\t" + custs[i].getGender() + "\t\t" + custs[i].getAge() + "\t\t" + custs[i].getPhone() + "\t\t" + custs[i].getEmail());
//                System.out.println((i+1) + "\t" + custs[i].getDetails());}}System.out.println("-------------------------客户列表完成-------------------------");}/*** @author: admin* @date: 2022/4/4 15:02* @description:创建CustomerView实例,并调用 enterMainMenu()方法以执行程序。* @Param args:* @return: void*/public static void main(String[] args) {CustomerView cView = new CustomerView();cView.enterMainMenu();}
}

CMUtility类的代码:

package p2.util;import java.util.*;
/**CMUtility工具类:将不同的功能封装为方法,就是可以直接通过调用方法使用它的功能,而无需考虑具体的功能实现细节。*/
public class CMUtility {private static Scanner scanner = new Scanner(System.in);/**用于界面菜单的选择。该方法读取键盘,如果用户键入’1’-’5’中的任意字符,则方法返回。返回值为用户键入字符。*/public static char readMenuSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false);c = str.charAt(0);if (c != '1' && c != '2' &&c != '3' && c != '4' && c != '5') {System.out.print("选择错误,请重新输入:");} else break;}return c;}/**从键盘读取一个字符,并将其作为方法的返回值。*/public static char readChar() {String str = readKeyBoard(1, false);return str.charAt(0);}/**从键盘读取一个字符,并将其作为方法的返回值。如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。*/public static char readChar(char defaultValue) {String str = readKeyBoard(1, true);return (str.length() == 0) ? defaultValue : str.charAt(0);}/**从键盘读取一个长度不超过2位的整数,并将其作为方法的返回值。*/public static int readInt() {int n;for (; ; ) {String str = readKeyBoard(2, false);try {n = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("数字输入错误,请重新输入:");}}return n;}/**从键盘读取一个长度不超过2位的整数,并将其作为方法的返回值。如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。*/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;}/**从键盘读取一个长度不超过limit的字符串,并将其作为方法的返回值。*/public static String readString(int limit) {return readKeyBoard(limit, false);}/**从键盘读取一个长度不超过limit的字符串,并将其作为方法的返回值。如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。*/public static String readString(int limit, String defaultValue) {String str = readKeyBoard(limit, true);return str.equals("")? defaultValue : str;}/**用于确认选择的输入。该方法从键盘读取‘Y’或’N’,并将其作为方法的返回值。*/public static char readConfirmSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false).toUpperCase();c = str.charAt(0);if (c == 'Y' || c == 'N') {break;} else {System.out.print("选择错误,请重新输入:");}}return c;}private static String readKeyBoard(int limit, boolean blankReturn) {String line = "";while (scanner.hasNextLine()) {line = scanner.nextLine();if (line.length() == 0) {if (blankReturn) return line;else continue;}if (line.length() < 1 || line.length() > limit) {System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");continue;}break;}return line;}
}

项目资源:

Java实现客户信息管理软件-Java文档类资源-CSDN下载Java实现客户信息管理软件更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/pxyp123/85076107

Java实现客户信息管理软件相关推荐

  1. java实现客户信息管理软件(功能展示)

    基于面向对象的思想,可以制作一个银行收支手账,涉及到封装性.关键字.构造器等面向对象的简单知识的综合应用 首先看一下具体的功能 首先是一个程序界面展示具体功能 主要包括增删改查功能,在选择具体的功能编 ...

  2. Java学习路线:day11 客户信息管理软件

    文章目录 转载自atguigu.com视频 客户信息管理软件 需求说明书 软件设计结构 第1步:封装CMUtility工具类 第2步:Customer类的设计 第3步:CustomerList类的设计 ...

  3. Java基础项目——客户信息管理软件

    目录 前言 本项目目标 一.需求及软件设计结构说明 1.需求说明 1)主菜单 2)添加客户 3)修改客户 4)删除客户 5)客户列表 2.软件设计结构 1)Customer类的设计 2)Custome ...

  4. Java项目二——客户信息管理软件

    目录 1.CMUtility工具类 2.客户类:Customer 3.客户信息管理类:CustomerList 4.CustomerView为主模块 二.程序的运行结果展示 1.添加客户 2.修改客户 ...

  5. Java 简单控制台项目之客户信息管理软件 --- 凌宸1642

    项目二:客户信息管理软件 模拟实现一个基于文本界面的<客户信息管理软件> 进一步掌握编程技巧和调试技巧,熟悉面向对象编程 主要涉及以下知识点: 类结构的使用:属性.方法及构造器 对象的创建 ...

  6. java se 学习之项目二:客户信息管理软件

    一.需求说明 模拟实现基于文本界面的<客户信息管理软件>. 该软件能够实现对客户对象的插入.修改和删除(用数组实现),并能够打印客户明细表. 项目采用分级菜单方式.主菜单如下: ----- ...

  7. 零基础Java学习之初级项目实践(客户信息管理软件-附源码)

    项目涉及知识点 基础的面向对象编程项目. 类和对象(属性.方法及构造器) 类的封装 引用数组 数组的插入.删除和替换 对象的聚集处理 多对象协同工作 需求说明 总体说明 模拟实现基于文本界面的< ...

  8. Java小项目—客户信息管理软件(二)

    CustomerView类的设计 CustomerView为主模块,负责菜单的显示和处理用户操作. 本类封装以下信息: 创建最大包含10个客户对象的CustomerList对象,供以下各成员方法使用. ...

  9. 【Java7】练习:选角色,挑苹果,员工类,换心脏,斗地主,发工资,客户信息管理软件,开发团队调度系统

    文章目录 1.玩家选择角色:return new 2.人工挑苹果:只一个接口CompareAble 3.员工类接口:implements Comparator 4. 医生帮换心脏:Organ类doWo ...

最新文章

  1. 为啥我从后台查到的值在页面显示的是undefined_再谈一个管理后台列表功能应有的素质...
  2. Three levels at which any machine carrying out an Information-Processing task must be understood
  3. 幼儿园python_[Python]猜数字游戏AI版的实现(幼儿园智商AI)
  4. fantouch os Android 7,Funtouch OS 3.1 with Android 7.1升级计划
  5. 电脑测速软件_iPerf3 搭建局域网内部测速环境
  6. arm 指令1(转)
  7. 网页设计上机考试原题_计算机二级考试即将到达战场,各单位准备!!!!
  8. php ssl 不验证失败,php – 没有SSL的安全身份验证
  9. 怎么向小学生解释欧拉公式 e^(πi)+1=0?
  10. redis将散裂中某个值自增_这些Redis命令你都掌握了没?
  11. 域名带后缀_[Python 爬虫]获取顶级域名及对应的 WHOIS Server 及 whoisservers.txt 下载...
  12. android.mk 强制编译,android.mk文件的编译
  13. 中国网吧 20 年往事,端游式微、手游主宰
  14. 在linux下安装iNode校园客户端
  15. Storm-Engine 基于 C++ 的开源游戏引擎
  16. Win11 Windows聚焦不更新了怎么解决?聚焦锁屏图片不更换怎么办
  17. win10笔记本电脑耳机没反应,耳机没声音的解决方法
  18. 解决iOS 15上图标出现对号的问题
  19. PC浏览器如何设置代理
  20. postman 一直Sending

热门文章

  1. 望远镜和相机是如何工作的
  2. ajax商城模板,AJAX模板
  3. 【附源码】计算机毕业设计SSM-农产品销售平台
  4. Python前端开发
  5. 一年一度的科技狂欢盛会——2022亚马逊云科技re:Invent全球大会
  6. C# .Framework生成条形码
  7. 房建工程项目智慧工地管理系统云平台
  8. 【转】MATLAB各种矩阵生成函数
  9. Mask RCNN(1): 网络详解
  10. java Date日期时间相减 精确到毫秒