由于某种原因没有找到saleID。该类调用它

时间:2015-05-24 12:44:35

标签: java try-catch

现在遇到问题,我把它更改为接受try和catch,现在它没有找到要比较的销售ID。

有人能够看到发生了什么吗? 它与getSaleID的调用方式有关吗?

private static void submitOffer() throws OfferException
{

  int offerPrice;
  boolean offerAccepted;

  System.out.print("Enter sale ID: ");
  String saleID = keyboard.nextLine();
  try
  {
     for (int i = 0; i < salesCount; i++)
     {
        if ( sales[i].getSaleID().equalsIgnoreCase(saleID))
        {   
           System.out.print("Enter offer price: ");
           offerPrice = keyboard.nextInt();
           keyboard.nextLine();
           System.out.println();
           //try!!!
           offerAccepted = sales[i].makeOffer(offerPrice);
           if (offerAccepted == true)
           {
              System.out.print("Offer was accepted"); 

              if(offerPrice <= sales[i].getReservePrice())
              {
                 System.out.print("Reserve Price was met");

              }
              else
              {
                 System.out.print("Reserve Price was not met");
              }
           }
           else
           {
              System.out.print("Offer was not accepted");
           }

        }

     } // for
  }
  catch(OfferException e)
  {
     System.out.print("That property with the sale ID " + saleID + "Does not exist");
     System.out.println();
  }

}

0 个答案:

没有答案