客户信息存储系统

本文介绍了客户信息存储系统的软件设计结构,主要包括CustomerView主模块,用于菜单展示和用户操作处理,CustomerList模块用于管理Customer对象,提供增删改查功能,而Customer对象则用于封装客户的具体信息。
摘要由CSDN通过智能技术生成
1.软件设计结构

在这里插入图片描述

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

/**
 * @BelongsProject: project02
 * @BelongsPackage: bean
 * @Author: mcc
 * @CreateTime: 2020-07-30 08:02
 * @Description: Customer为实体对象,用来封装客户信息
 */
public class Customer {
   
    private String name;//客户姓名
    private char gender;//性别
    private int age;//年龄
    private String phone;//电话号码
    private String email;//电子邮箱

    public Customer() {
   
    }

    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 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;
    }
}

package service;

import bean.Customer;

/**
 * @BelongsProject: project02
 * @BelongsPackage: service
 * @Author: mcc
 * @CreateTime: 2020-07-30 07:56
 * @Description: CustomerList为Customer对象的管理模块,内部用数组管理一组Customer对象,
 * 并提供相应的添加、修改、删除和遍历操作,供CustomerView调用
 */
public class CustomerList {
   
    private Customer[] customers;//用来保存客户对象的数组
    private int total = 0;//记录已保存客户对象的数量

    /**
     * 用来初始化customers数组的构造器
     *
     * @param totalCustomer:指定数组的长度
     */
    public CustomerList(int totalCustomer) {
   
        customers = new Customer[totalCustomer];
    }

    /**
     * 将指定的客户添加到数组中
     *
     * @param customer
     * @return true:添加成功 false:添加失败
     */
    public boolean addCustomer(Customer customer) {
   
        if (total >= customers.length) {
   
            return false;
        }
        customers[total] = customer;
        total++;
        return true;
    }

    /**
     * 修改指定索引位置的客户信息
     *
     * @param index
     * @param cust
     * @return true:修改成功 false:修改失败
     */
    public boolean replaceCustomer(int index, Customer cust) {
   
        if (index < 0 || index >= total) {
   
            return false;
        }
        customers[index] = cust;
        return true;
    }

    /**
     * 删除指定索引位置的客户
     *
     * @param index
     * @return true:删除成功 false:删除失败
     */
    public boolean deleteCustomer(int index) {
   
        if (index < 0 || index >= total) {
   
            return false;
        }
        for (int i = index; i < total - 1; i++) {
   
            customers[i] = customers[i + 1];
        }
        //最后有数据的元素需要置空
        customers[total - 1] = null;
        total--;
        return true;
    }

    /**
     * 获取所有的客户信息
     *
     * @return
     */
    public Customer[] getAllCustomers() {
   
        Custo
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值