Coder Social home page Coder Social logo

movie-theater-seating's Introduction

Movie-Theater-Seating

Table of Contents

Overview

This project is a coding challenge where you are given the challenge of creating a algorithm for assigning seats within a movie theater in order to fulfill reservation requests. The goal of the challenge is to maximize both customer satisfaction and customer safety (for public safety, a buffer of 3 seats is required).

You are given a file with one line of input for each reservation request. The order of the lines reflects the order in which the reservation requests were recieved. Each line is comprised of a reservation identifier, followed by a space, and then the number of seats requested. The reservation identifier will have the format: R####.

The program should output a file containing the seating assignments for each request. Each row in the file should include the reservation number followed by a space, and then a comma-delimitted list of the assigned seats.

Assumptions

In coming up with my solution, I made the following assumptions:

  • Theater arrangement defaults to 10 rows with 20 seats per row
  • For public safety, each group would like to have a 3 seat buffer from any other groups in same row
  • Reservation requests are processed in the order they come in
  • Customers would prefer to be seated towards the middle rows of the movie theater

How to Run

This program was built in Visual Studio Code. In order to run follow the following steps:

  • Switch Terminal shell from PowerShell to Command Prompt
  • Compile the Java program with the following line: javac Main.java <-- Make sure that the .class files are created for each .java
  • Run the Java program with the following line: java Main input.txt <-- Change input.txt to whichever input file you would like to use in the directory
  • Alternatively, you can also specify the full path to run: java Main "D:\GitHub\Interview\Movie-Theater-Seating\input.txt"

Class Diagram

MovieTheaterSeating drawio

Code

A brief description of all of the files is as follows:

  • The exactFullInput file tests the edge case where a reservation is for every seat in the theater (200 seats).
  • The fullInput file tests the edge case where certain reservations are unable to be allocated due to there not being enough seats left.
  • The input file tests several reservations with small group sizes.
  • The Main class contains the main method and is the basis for running the program.
  • The output file has all of the reservation seating outcomes written to it.
  • The Reservation class represents the reservation class and is used to keep track of seating for reservation + printing reservation details.
  • The Theater class contains the seating status of the theater, assigns seats and holds all of the reservations.

Technologies

  • Visual Studio Code
  • GitHub
  • GitHub Desktop

movie-theater-seating's People

Contributors

sergeibak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.