dimanche 17 décembre 2017

Data structure for movie-theatre two way searching capability

I am trying to design a online Movie ticket booking system where a user can search a movie/theater in a given city and then book a movie. Suppose he searched for a movie, I need to return that movie with all theaters along with the show timings for that movie. Similarly, if he searches for a theater, I need to return that theater with all movies in that theater along with show timings. I have no way to figure out if it's a movie or theater that user is searching. Which data structure should I use for efficient search? Here is what I thought of but it seems to be a brute force approach. Here is my class (partial structure)

public class Theater {
  String theaterName;
  ArrayList<Movies> movies;
}

Suppose I store theaters as arraylist, I would end up parsing these theaters and making string comparisons with theater name and subsequently with movie names.

Aucun commentaire:

Enregistrer un commentaire