发布网友 发布时间:2024-10-23 19:20
共2个回答
热心网友 时间:2024-11-06 19:03
public class Customer {
private String customerName;
private int age;
private boolean isValid ;
public Customer(String customerName, int age, boolean isValid) {
super();
this.customerName = customerName;
this.age = age;
this.isValid = isValid;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isValid() {
return isValid;
}
public void setValid(boolean isValid) {
this.isValid = isValid;
}
}
import java.util.ArrayList;
import java.util.List;
public class CustomerBiz {
private List<Customer> customerList = new ArrayList<Customer>();
public void addCustomer(Customer customer){
customerList.add(customer);
}
public void showCustomers(){
Customer customer = null;
System.out.println("客户信息:");
for(int i=0;i<customerList.size();i++){
customer = customerList.get(i);
System.out.println(customer.getCustomerName()+" "+customer.getAge()+" "+customer.isValid());
}
}
public static void main(String[] args){
CustomerBiz customerBiz = new CustomerBiz();
customerBiz.addCustomer(new Customer("王一",30,false));
customerBiz.addCustomer(new Customer("郝强",19,true));
customerBiz.showCustomers();
}
}
热心网友 时间:2024-11-06 19:01
这个太简单了,自己摸索一下