Пример #1
0
  public static void registerRoom() throws IOException, Exception {
    // get hotel name
    System.out.println("Enter the hotel ID:");
    String hotelID = bufferRead.readLine();

    // get room number
    System.out.println("Enter the room number: ");
    String roomNo = bufferRead.readLine();

    // get guest ID
    System.out.println("Enter the guest ID: ");
    String guestID = bufferRead.readLine();

    // get start date
    System.out.println("Enter the start date (YYYY-MM-DD): ");
    String start = bufferRead.readLine();

    while (!Booking.isDateValid(start)) {
      System.out.println("Invalid: Please enter start date in this format (YYYY-MM-DD):");
      start = bufferRead.readLine();
    }

    // get end date
    System.out.println("Enter the end date (YYYY-MM-DD): ");
    String end = bufferRead.readLine();

    while (!Booking.isDateValid(end)) {
      System.out.println("Invalid: Please enter end date in this format (YYYY-MM-DD):");
      end = bufferRead.readLine();
    }

    // book a room
    Booking.bookRoom(conn, hotelID, roomNo, guestID, start, end);
  }
Пример #2
0
  public static void searchHotels() throws IOException, Exception {
    // get hotel name
    System.out.println("Enter the hotel name, or press enter to skip: ");
    String hotel = bufferRead.readLine();
    hotel = hotel.length() == 0 ? null : hotel;

    // get city input
    System.out.println("Enter the city (Waterloo, Guelph, Kitchener), or press enter to skip: ");
    String city = bufferRead.readLine();
    city = city.length() == 0 ? null : city;

    // get price input
    System.out.println("Enter the room price (between 50.00 and 250.00), or press enter to skip: ");
    String price = bufferRead.readLine();
    price = price.length() == 0 ? null : price;

    // get room type
    System.out.println(
        "Enter the room type (Single, Double, King, Queen), or press enter to skip: ");
    String type = bufferRead.readLine();
    type = type.length() == 0 ? null : type;

    // get start date
    System.out.println("Enter the start date (YYYY-MM-DD): ");
    String start = bufferRead.readLine();

    while (!Booking.isDateValid(start)) {
      System.out.println("Invalid: Please enter start date in this format (YYYY-MM-DD):");
      start = bufferRead.readLine();
    }

    // get end date
    System.out.println("Enter the end date (YYYY-MM-DD): ");
    String end = bufferRead.readLine();

    while (!Booking.isDateValid(end)) {
      System.out.println("Invalid: Please enter end date in this format (YYYY-MM-DD):");
      end = bufferRead.readLine();
    }

    // check valid rooms
    Booking.findRoom(conn, start, end, hotel, city, price, type);
  }