顾客管理系统具体实现功能
使用eclipce编译器,JDK版本:16.0.2
- 添加客户信息
- 修改客户信息
- 删除客户信息
- 查找客户列表
- 退出系统
软件设计结构
该软件由以下三个模块组成:
- CustomerView为主模块,负责菜单的显示和处理用户操作。
- CustomerList为Customer对象的管理模块,内部用数组管理一组Customer对象,并提供相应的添加,修改,删除和遍历方法,供CustomerView调用
- Customer为实体对象,用来封装客户信息。
- 工具类CMUtility,用来实现键盘响应。
CustomerView代码片段
public class CustomerView {
private CustomerList customerList =new CustomerList(10);//通过创建CustomerList对象来进行增删查改的操作
//CustomerView无参构造方法
public CustomerView() {
//Customer customer=new Customer("王涛",'男',23,"13212341234","wt@gmail.com");
//customerList.addCustomer(customer);
}
public void enterMainMenu() {
boolean isFlag=true;
while(isFlag) {
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 menu=CMUtility.readMenuSelection();//读取键盘操作
switch(menu) {
case'1':
addNewCustomer();//增加
break;
case'2':
modidyCustomer();//修改
break;
case'3':
deleteCustomer();//删除
break;
case'4':
listAllCustomers();//显示
break;
case'5':
System.out.print("是否确认退出(Y/N):");
char isExit=CMUtility.readConfirmSelection();//读取键盘操作
if(isExit=='Y') {
isFlag=false;//退出循环
}
}
}
}
private void addNewCustomer() {
System.out.println("-----------------添加客户-----------------\n");
System.out.print("姓名: ");
String name=CMUtility.readString(10);
System.out.print("性别: ");
char gender =CMUtility.readChar();
System.out.print("年龄: ");
int age=CMUtility.readInt();
System.out.print("电话: ");
String phone=CMUtility.readString(13);
System.out.print("邮箱: ");
String email=CMUtility.readString(30);
Customer customer=new Customer(name,gender,age,phone,email);//将所有属性的值封装到customer
boolean isSuccess=customerList.addCustomer(customer);//调用customerList 增加客户信息
if(isSuccess) {
System.out.println("-----------------添加完成-----------------\n");
}else {
System.out.println("-----------------客户目录已满,添加失败-----------------\n");
}
}
private void modidyCustomer(