Theatre seat booking system in java using the ArrayList class which implements the List interface
Here is an implementation of Theatre Booking System using ArrayList in Java.
ArrayList is a member of the Java Collections Framework. It implements the List Interface and can implement all the defined methods of the interface. Also implementation of ArrayList is not synchronized.
ArrayList has an edge over normal arrays as it is dynamic, that is, it is re-sizeable. We can easily manipulate its size as per the number of elements.
In the given program, we have an array of a customized object called Seat. The class Seat is inner class of the class Theatre.
We have also implemented the Comparable interface to list the theatre seats in order. Comparable interface in java is used to sort a list consisting of customized objects.
We have also used Java Comparator interface to display the theatre seats in sorted order by overriding the Compare method.
In order to search for a particular seat in the arraylist we have used the built-in method of binary search of the Collection framework. The time complexity of binary search is much less than usual brute-force technique.
Submitted by Harshita Shree (harshita)
Download packets of source code on Coders Packet
Comments