JAVA 编程练习0_1-------------顾客管理系统(简易)

顾客管理系统具体实现功能

使用eclipce编译器,JDK版本:16.0.2

  1. 添加客户信息
  2. 修改客户信息
  3. 删除客户信息
  4. 查找客户列表
  5. 退出系统

在这里插入图片描述

软件设计结构

该软件由以下三个模块组成:在这里插入图片描述

  1. CustomerView为主模块,负责菜单的显示和处理用户操作。
  2. CustomerList为Customer对象的管理模块,内部用数组管理一组Customer对象,并提供相应的添加,修改,删除和遍历方法,供CustomerView调用
  3. Customer为实体对象,用来封装客户信息。
  4. 工具类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(
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值