我想获得的不仅仅是来自arrayList(Rental)的可用日期,而是来自arrayList(Resort)。不幸的是,我无法比较两者,我得到的输出是arrayList(Rental)。
public static void listavailableResort(ArrayList resortList, ArrayList rentalList)
{
Resort rt;
Rental rl;
Person p;
boolean availresort = false;
boolean availrental = false;
//viewing available resortList from rentalList
for (int i = 0; i<resortList.size();i++)
{
availresort = true;
rt =(Resort)resortList.get(i);
for (int k = 0; k< rentalList.size();k++)
{
availrental = true;
rl = (Rental)rentalList.get(k);
//Compare between the user entered and the rentalList
//start is arrivaldate end is departuredate
if(((!(start.equals(rl.getarrivalDate())))&&(!(end.equals(rl.getDepartureDate()))))||((start.before(rl.getarrivalDate()))&&(end.before(rl.getDepartureDate()))) || ((start.after(rl.getarrivalDate())))&&(end.after(rl.getDepartureDate())))
{
rt = rl.getresort();
if (rt instanceof Chalet)
{
//how to check if two date are equals
Chalet t = (Chalet)rt;
System.out.println((i+1)+"\t"+t.getresortID()+"\t"+t.getblock()+"\t"+t.getunitNumber());
}
else if(rt instanceof Bungalow)
{
Bungalow b =(Bungalow)rt;
System.out.println((i+1)+"\t"+b.getresortID()+"\t\t"+b.getblock()+"\t\t\t\t"+b.getwifi()+"\t\t "+b.getrate());
}
}
else
{
if (rt instanceof Chalet)
{
//how to check if two date are equals
Chalet t = (Chalet)rt;
System.out.println((i+1)+"\t"+t.getresortID()+"\t"+t.getblock()+"\t"+t.getunitNumber());
}
else if(rt instanceof Bungalow)
{
Bungalow b =(Bungalow)rt;
System.out.println((i+1)+"\t"+b.getresortID()+"\t\t"+b.getblock()+"\t\t\t\t"+b.getwifi()+"\t\t "+b.getrate());
}
}
}
如果编码混乱,我道歉...我只需要知道如何比较输入(Scanner)和arrayList(从rentalList(arrivalDate和departuredate)获取)
很多人