top of page

Hotel booking information I Java assignment help

Task Description

Please write a program in Java to sort and search hotel booking information. The public interface of Booking Manager is described below, along with a ready-to-use class Booking Info. Please follow the requirements in the description for each method to complete this class. Please also write a tester class to thoroughly test the four methods given in Booking Manager.

The Booking Manager class should contain the following public methods:


1. public Array List <Booking Info> read Bookings (string path Name) throws IOException:

  • Read all the booking information from the binary file in the local file system as specified by the parameter path Name and return an Array List of Booking Info.

  • We assume that each record in the binary file has a fixed length of 60 bytes, with start date stored in the first 20 bytes, end date in next 20 bytes, and id in the last 20 bytes.

  • We assume that all the dates in the file are in the format of YYYY-MM-DD. There could be an arbitrary number of records in the file.

2. public Array List<Booking Info> sort Bookings (Array List<Booking Info> input List):

  • Write code that implements the merge sort algorithm to sort all the booking information in input List by start date in a way that recent info shows first. The method returns the list of sorted bookings.

3. Public Array List<Booking Info> remove Conflicts (Array List<Booking Info> input List):

  • Use the sorted list of booking info (input List) to find if there are pairs of bookings with conflict. Having a conflict means that a booking has a start date before the end date of another booking. Whenever there is a conflict, remove the later one. The method returns a new list of booking info with no conflicts.

4. public void save Booking Info (String path Name, Array List <Booking Info> sorted List) throws IOException:

  • Use Random Access File to save all the ordered booking info from the sorted List to the given path Name on the disk.

5. public Array List<Booking Info> booking Search(String path Name, Date min Date, Date max Date) throws IOException:

  • Given the date range [min Date, max Date] (both inclusive) and the pathname of the file that stores the sorted booking info, use binary search to find and return an Array List of all the booking info within this date range without loading all the booking info in the file into memory (i.e., do NOT attempt to read all booking info into an array/Array List and then perform the search there). If no booking info falls in the date range, the method returns an empty list. As a hint, one way to complete this method is to adapt the binary search algorithm (for arrays) taught in class to the setting of random access files. To retrieve the booking info in a range, you may use binary search to locate within the range the booking info with the given min Date (or if such a booking info does not exist, the first booking info that has a start date that is higher than min Date in the file) and then visit the subsequent records until the date is out of the given range or the end of the file is reached.

  • Tips: 1.Use Random Access File(). seek (long pos) to do random access; Use Random Access File().length() to get the size of file (number of bytes).


What to submit

Submit BookingManager.java only. Please use the exact file name, class name, and method names given here and document it properly using Java Doc. Nothing else (including BookingInfo.java, the tester class, and the data files) should be submitted. Compile and test your code under the command line environment (e.g., by executing Terminal under macos or cmd under Windows). DO NOT submit .class files! The file BookingManager.java ONLY.


For Complete solution of this sample assignment mail us on contact@codersarts.com


Also, If you are looking for any kind of coding help in programming languages, Contact us for instant solution




bottom of page