0

我只想从 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());      
                  }  
               }  
            }

如果编码混乱,我深表歉意......我只需要知道如何比较输入(扫描仪)和数组列表(从出租列表获取(到达日期和出发日期))

许多想法

4

0 回答 0