我目前有2个Arraylist
,其中包含Customer
和Bike
构造函数数据。我成功输入了两者,以便使用以下方式租借Arraylist
:
rent.add(new Rent(customers.get(1),bike.get(1)));
我如何检查CustomerID
是否已经有Arraylist
租金,并且会出现错误提示客户已经在租房?
public Rent(Customer customer, Bike bike) {
this.customers = customer;
this.bike = bike;
}
public Customer(int CustID, String CustFName, String CustLName) {
this.CustID = CustID;
this.CustFName = CustFName;
this.CustLName = CustLName;
}
public Bike(int BikeID, String BikeType, int PricePerDay,booleanisAvailable) {
this.BikeID = BikeID;
this.BikeType = BikeType;
this.PricePerDay = PricePerDay;
this.isAvailable = isAvailable;
}
protected ArrayList<Customer> customers = new ArrayList<Customer();
protected ArrayList<Bike> bike = new ArrayList<Bike>();
protected ArrayList<Rent> rent = new ArrayList<Rent>();