package porjectText02.service;
import projectText02.bean.Customer;
public class CustomerLi {
private Customer[] customers; //创建Customers对象的数组
//Customers类是私有的,因此需要调用import projectText02.bean.Custmoers
private int total = 0; //记录以保存客户对象的数量
//指定数组的最大空间长度:totalCustomer
public CustomerLi(int totalCustomer) {
customers = new Customer[totalCustomer];
}
//指定要添加的客户对象
public boolean addCustomer(Customer customer) {
if(total >= customers.length)
return false;
customers[total++] = customer;
return true;
}
//指定要替换的客户对象
public boolean replaceCustomer(int index,Customer cust) {
if(index < 0 || index >= total) {
return false;
}
customers[index] = cust;
return true;
}
//删除指定索引位置上的客户
public boolean deleteCustomer(int index) {
if(index < 0 || index >= total) {
return false;
}
for(int i = index;i < total -1 ;i++) {