Customer类: 内有客户信息等属性
public class Customer {
private String name;
private String gender;//性别
private int age;
private String phone;
private String email;
public Customer() {
}
public Customer(String name,String gender,int age,String phone,String email){
this.name=name;
this.age=age;
this.email=email;
this.gender=gender;
this.phone=phone;
}
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
public String getGender() {
return gender;
}
public void setGender(String 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;
}
}
CustomerList类:储存客户信息列表,实现对列表的操作
public class CustomerList {
private Customer[] customers;
int total=0;//客户数量
//初始化数组的构造器,指定数组的长度
public CustomerList(int totalCustomer) {
customers=new Customer[totalCustomer];
}
//将指定的客户添加到数组中
public boolean addCustomer(Customer customer) {
if(total>=customers.length) {
return false;
}else {
customers[total]=customer;
total++;
return true;
}
}
//修改指定位置的客户信息
public boolean replaceCustomer(int index,Customer cust) {
if(index>=total||index<0) {
return false;