public ws.niceview.types.HotelListType getHotels(
      java.lang.String city, XMLGregorianCalendar departureDate, XMLGregorianCalendar arrivalDate) {

    HotelListType hotelList = new HotelListType();
    boolean randomize = false;
    Random rand = null;

    if (city.equals("SleepCity")) {
      try {
        Thread.sleep(10000);
      } catch (InterruptedException ex) {
        Logger.getLogger(NiceViewWebServiceFromWSDL.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    if (arrivalDate.getDay() - departureDate.getDay() > DAY_LIMIT) {
      randomize = true;
      rand = new Random(System.currentTimeMillis());
    }

    /*if (arrivalDate.get(java.util.Calendar.DAY_OF_YEAR) -
    departureDate.get(java.util.Calendar.DAY_OF_YEAR) > DAY_LIMIT) {
    randomize = true;
    rand = new Random(System.currentTimeMillis());
    }*/

    for (HotelType hotel : hotelArray) {

      if (hotel.getHotelAddress().getCity().equalsIgnoreCase(city)) {
        if (randomize) {
          if (rand.nextBoolean()) {
            hotelList.getHotel().add(hotel);
          }

        } else {
          hotelList.getHotel().add(hotel);
        }
      }
    }

    hotelList.setHotelReservationServiceName("FormuleUn"); // Add by KB

    return hotelList;
  }
  private HotelType createHotel(
      String hotelName,
      String hotelStreet,
      String hotelPostcode,
      String hotelCity,
      String bookingNumber,
      double stayPrice,
      boolean ifCreditCardGuaranteeRequired) {

    HotelType hotel = new HotelType();

    hotel.setHotelName(hotelName);

    AddressType hotelAddress = new AddressType();
    hotelAddress.setStreet(hotelStreet);
    hotelAddress.setPostcode(hotelPostcode);
    hotelAddress.setCity(hotelCity);
    hotel.setHotelAddress(hotelAddress);

    hotel.setBookingNumber(bookingNumber);
    hotel.setHotelStayPrice(stayPrice);
    hotel.setIfCreditCardRequired(ifCreditCardGuaranteeRequired);

    return hotel;
  }
  public boolean bookHotel(java.lang.String bookingNumber, CreditCardInfoType creditCardInfo)
      throws BookHotelFault, BookHotelCreditCardFault {
    if (bookingNumber == null || "".equals(bookingNumber)) {
      throw new BookHotelFault("Booking number was not provided", new BookHotelFaultType());
    }

    if (creditCardInfo == null) {
      throw new BookHotelCreditCardFault(
          "Credit Card Info was not provided", new CreditCardFaultType());
    }

    if (creditCardInfo.getNumber() == null || "".equals(creditCardInfo.getNumber())) {
      throw new BookHotelCreditCardFault(
          "Credit Card Number was not provided", new CreditCardFaultType());
    } else if (creditCardInfo.getName() == null || "".equals(creditCardInfo.getName())) {
      throw new BookHotelCreditCardFault(
          "Credit Card Name is empty or was not provided", new CreditCardFaultType());
    } else if (creditCardInfo.getExpirationDate().getMonth() == 0
        || creditCardInfo.getExpirationDate().getYear() == 0) {
      throw new BookHotelCreditCardFault(
          "Credit Card Expiration Date was not provided", new CreditCardFaultType());
    }

    HotelType currentHotelToBook = new HotelType();

    for (HotelType hotel : hotelArray) {
      if (bookingNumber.equals(hotel.getBookingNumber())) {
        currentHotelToBook = hotel;
        break;
      }
    }

    if (!bookingNumber.equals(currentHotelToBook.getBookingNumber())) {
      throw new BookHotelFault(
          "Hotel for booking number " + bookingNumber + " does not exist",
          new BookHotelFaultType());
    }

    dk.dtu.imm.fastmoney.BankPortType port = service.getBankPort();

    int amount = (int) currentHotelToBook.getHotelStayPrice();

    // Card Validation - only if credit card guarantee is required

    if (currentHotelToBook.isIfCreditCardRequired()) {

      try {
        boolean validationResult = port.validateCreditCard(GROUP_NUMBER, creditCardInfo, amount);

      } catch (CreditCardFaultMessage ex) {
        CreditCardFaultType fault = new CreditCardFaultType();
        fault.setMessage(ex.getMessage());
        throw new BookHotelCreditCardFault(
            "Invalid credit card info provided or amount of money to be charged is not guaranteed",
            fault);
      }
    }

    // Card Charging

    account.setName("NiceView");
    account.setNumber("50308815");

    try {
      boolean chargingResult = port.chargeCreditCard(GROUP_NUMBER, creditCardInfo, amount, account);
    } catch (CreditCardFaultMessage ex) {
      CreditCardFaultType fault = new CreditCardFaultType();
      fault.setMessage(ex.getMessage());
      throw new BookHotelCreditCardFault("Credit card cannot be charged", fault);
    }

    bookedHotels.add(currentHotelToBook.getBookingNumber());

    return true;
  }