用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<customers.length)
{
customers[total]=customer;
total++;
return true;}
else
{
return false;}
}
/**
*替换
* @param index 指定的客户的编号
* @param cust 修改的客户
* @return 返回是否修改成功
*/
public boolean replaceCustomer(int index,Customer cust){
if(index>=0 && index <total )
{
customers[index]=cust