Technical University of Denmark DTU
02115   Java Programming
Autumn 2011

Mandatory Assignment

A simple Cinema Booking System


The problem

The problem to be solved is to register bookings for persons visiting cinemas either for viewing the screening of a movie or for enjoying a refreshment at a table (or both).
Your program must handle the commands given below.

The model of your system must contain the class CinemaSystem holding a set of public methods - if convenient only a main method - together with the additional classes you find appropriate.
The user interface has to handle two different kinds of users:

  1. The customers who are looking for either a screening of a movie on a certain day or want either to book some tickets or a table at a specific cinema theatre
  2. The system administrator who sets up the system defining cinema theatres and shows (films attached to cinemas at certain days) and does other system related operations

The final solution must have both a command line based user interface and a GUI, just as illustrated with the address-book family of projects in Chapter 12 of the BK textbook. It's important to state that the same system model should be used without needing any changes when switching between the two user interfaces.


In the first part of the assignment develop the system with a command line based user interface where commands are written one by one and then read, parsed and executed. That interface is well-suited for testing the model.

In the second part of the assignment a GUI interface has to be added. The choice of user interface offered to the customers is probably a matter of system setup done by the administrator. Feel free to make your own proper choice which also allows a switching between the two interfaces.
The system could be considered a kind of client-server system where customers are the clients, the audience.


The model of the system should have the following main properties:



Simplifications to the model:

The commands

In the set of commands given below one can distinguish between three different kinds of commands. Some commands are directed towards the administator - user mode equals ADMIN, some are applicable only to the customers - user mode equals CUSTOMER, and some may be used by both.

When program execution starts only administator commands must be executed.

Command Parameters Description
mode user The command sets the user to be either administator or customer.
The parameter user has to be either ADMIN or CUSTOM
addCinema cinema name The command adds a cinema hall to the system - user mode must be ADMIN.
The parameters are:
The cinema name identifying the cinema, the number of rows of seats in the cinema (≤ 30), the number of seats of each row (≤ 20) given by rowLength and the number of tables (≥ 0 and ≤ 25)
rows
rowLength
number of tables
addShow film name The command adds a show to the system - user mode must be ADMIN.
The parameters are:
The film name identifying the film to be played in the cinema given by cinema name on the days stated by day names.
The day names is a list of days, e.g. Mon Thu Sat
cinema name
day names
addFrom file name The command adds from a file cinema halls and shows to the system - user mode must be ADMIN.
The parameter file name identifies the file holding informations on the cinemas and shows to be added:
Each line of the file holds either an addCinema command or an addShow command
load file name The command initializes the system with the state previously stored in a file by use of the save command below - user mode must be ADMIN.
The parameter file name identifies the file holding informations on the defined cinemas, shows and bookings done in a previous run of the program where the state has been saved to that file
save file name The command saves the state of the system in a file - user mode must be ADMIN.
The parameter file name identifies the file which should hold informations on the defined cinemas, shows and bookings done in the actual run of the program
when film name The command lists the names of days on which the film identified by film name is shown. All shows are searched
where film name The command lists the names of all cinemas showing the film identified by the specified film name on the day specified by day name
day name
tables day name The command lists the names of all cinemas having free tables together with the actual number of free tables for each cinema on the day specified by day name
book person name The user mode has to be CUSTOM
The command either books a number of seats in a cinema hall for a film shown in that cinema on the day specified or a table attached to that cinema on that day.
The command takes 3 or 5 parameters:
The person name to identify the person doing the booking, the cinema hall given by cinema name, the day stated by day name, and when booking for a movie screening and not just for a table then also the film name identifying the movie screened and last the number of seats to be booked
cinema name
day name
film name
number of seats
show booking number List booking informations corresponding to the stated booking number
showAll person name List all bookings done by the specified person name
Each booking should be presented in the same format as that used by the show command but preceded with the corresponding booking numbers for each booking information
exit   Stop running the program - the user mode has to be ADMIN


General comments on the commands

To set up the system in the first run the administrator has to
When in ADMIN mode the administrator may use the commands save, load and exit
Only use load as the very first command in a new run when it should be a strict continuation of the system state after a save from a previous run.

The book command used with 5 parameters is for reserving seats to a show.

The book command used with 3 parameters is for reserving a table.

The methods responsible for the execution of the commands should of course for each command store the resulting data in proper chosen objects some of which should be elements of collections



Example commands

The commands given here constitute a legal sequence of commands:

      addCinema City_Theatre 25 10 15
      addShow The_Hidden_Person City_Theatre Mon Wed
      mode CUSTOM
      when The_Hidden_Person
      tables Mon
      book Peter_Thomsen City_Theatre Wed The_Hidden_Person 5
      book Peter_Thomsen City_Theatre Wed
      showAll Peter_Thomsen 
      mode ADMIN
      exit

Comments on the example commands above:



Legal commands

The legality of a command must be secured by performing some tests. For e.g. the addCinema command one has to make sure that Analyse yourself each command and state the tests needed (included parameter tests) to secure the legality of the command and the legality of executing it.


Details on executing a command

The commands given should be executed one by one, each giving in user reply a string (possibly empty) before the next command is entered and executed. It's up to the user interface to handle the reply properly, maybe dependant on the user mode being ADMIN or CUSTOM

An attempt to execute an illegal command should cause an error reaction. Be aware of the fact that not all command sequences are legal.

The execution of legal commands will cause a state change of the cinema booking system, except for the commands when, where, tables, show and showAll.

The execution of a legal book command will couple a unique booking number to the booking made. This number may later be used in the show command to identify and look up a booking.
Bookings can also be looked up by a showAll command having a person name as parameter.
Analyse the need to uniquely identify a person by his/her person name


General remarks

Your design and implementation should be the result of following the guidelines of the BK textbook. The Chapters 13 and 14 suggest a methodology for the work to be carried out. The principles should be followed, but the workout should not necessarily be done exactly the way suggested.

How flexible is your design ?
Choose the collection classes guided by the requirements set by the commands to ease the execution of the commands (e.g. introducing maps for easy look ups)
Would it be easy to add more theatres to a cinema ?

You are not allowed to use tools which automatically generate classes. But tools supporting your editing of source code are allowed. So all Java code including the GUI parts has to be handwork. The GUI must not be constructed using a drag and drop tool. So, you are not allowed to use the NetBeans IDE's GUI builder, because that tool lets you visually construct your Graphical User Interface.


Practical information

Information on the contents and the structure of the report, and on handing in your solution are given separately.


Jens Thyge Kristensen, Email: jtk@imm.dtu.dk

Newest edition: 23. November (some minor language corrections)
Previous editions:
    - 10. October (one minor language correction)
    -   6. October (NetBeans IDE's GUI builder is not allowed to use)
    -   5. October