Thursday, January 23, 2014

Movie Ticket Booking in Java, Java Assignment

, 6 comments

Java Assignment: Theatre Tickets


Solution of this assignment is available 

To get mail me at sarfaraj.lpu@gmail.com


SPECIFICATIONS

You have been hired to write a program to manage the ticket office of a theatre. Your program will sell tickets and assign seats to people based on input containing ticket requests and cancellations of ticket orders. Periodically, you are asked to display the current status of all tickets and customers.

Input/output

The input consists of two different parts. The first part contains two numbers – the number of rows in the theatre and the number of seats per row. The rows are numbered starting at 1. You may assume there are at most 100 rows. Seats are numbered from left to right. You may not assume any bound on the number of seats per row.

The second part of the input contains ticket requests and cancellations. There are four different commands (see below). Commands are free format; an arbitrary number of blanks and end-of-lines may occur between fields in a command. Names in a command are at most 10 characters long.



Commands



REQUEST (person) (number)

The given person requests the indicated number of tickets. Further, our theatre-goers are a little finicky; they require that all tickets in each particular request be for consecutive seats in the same row. In addition, they must be given the row with the smallest possible number. If there are several blocks in the row that are large enough, the theatre-goers must be given the seats that are as far to the left as possible (see an example later). You must follow this seat allocation policy. If there is no block of available seats large enough, the person's request goes onto a waiting list. It is possible that later cancellations will free up a suitable block of seats. After processing the person's request, print a message indicating which seats (if any) he or she was allocated or whether the request was put on the waiting list.

CANCEL (person)

The given person cancels a ticket request. If this person has made several requests, all of them are cancelled. If this person is on the waiting list, his or her name is crossed off the list. If this person has been allocated a block of tickets, the tickets are freed. This may allow people on the waiting list to be served. Before reading in any more requests, go down the waiting list, allocating tickets until someone cannot be served (or until we reach the end of the list). If someone cannot be served, do not skip over him or her and look at people lower on the list; read in the next request instead. After processing the cancellation, print out a message that the person's order was cancelled and which (if any) people were allocated seats.


STATUS

Print out in a readable format: (1) The names of the people who have been allocated seats and which seats they were allocated (This list does not have to be sorted; the people can occur in any order. If a person has several blocks of tickets, they do not have to be printed out consecutively.) (2) The names of people on the waiting list and the sizes of their requests.

END

End of input; quit processing.

Data structures

You will need data structures for storing
1. What people have been given which tickets
2. What seats are available
3. The waiting list

THEATRE


x
x
x
x
x
x
x
x




x


x
x
x










x


 1      2     3     4      5     6       7  seat numbers
x = not available
3
2 row numbers
1

Sample



Input

3 7
REQUEST Wagner 4
REQUEST Brahms 5
REQUEST Wagner 4
REQUEST Beethoven 1
REQUEST Handel 3
REQUEST Liszt 7
REQUEST Wagner 4
REQUEST Berlioz 3
STATUS
CANCEL Wagner
STATUS
REQUEST Vivaldi 2
CANCEL Beethoven
REQUEST Bach 4
STATUS CANCEL Brahms STATUS
END


Selected output

The output of the STATUS commands is shown below. (The diagrams of the theatre are for purposes of illustration; you should print them in any way that will result in output that is compatible with an ASCII file.)

Output of the first STATUS command:

TICKETS:


Wagner
Row 1
Seats 1
through 4
Brahms
Row 2
Seats 1
through 5
Wagner
Row 3
Seats 1
through 4
Beethoven
Row 1
Seats 5
through 5
Handel
Row 3
Seats 5
through 7

WAITING LIST:

Liszt
7
Wagner
4
Berlioz
3

x
x
x
x
x
x
x
x
x
x
x
x




x
x
x
x
x





SEATING PLAN:

3
2
1
1 2 3 4 5 6 7
Brahms
Row 2
Seats 1
through 5
Beethoven
Row 1
Seats 5
through 5
Handel
Row 3
Seats 5
through 7

WAITING LIST:

Liszt 7
Berlioz 3










x
x
x
x
x
x
x
x




x
x
x
x
x
x



SEATINGPLAN:
3
2
1
1 2 3 4 5 6 7



Output of the third STATUS command:


TICKETS:



Brahms
Row 2
Seats 1
through 5
Handel
Row 3
Seats 5
through 7
Vivaldi
Row 1
Seats 1
through 2
Bach
Row 1
Seats 3
through 6

WAITING LIST:

Liszt 7
Berlioz 3










x
x
x
x
x
x
x
x




x
x
x
x
x
x



SEATING PLAN:

3
2
1
1 2 3 4 5 6 7
Handel
Row 3
Seats 5
through 7
Vivaldi
Row 1
Seats 1
through 2
Bach
Row 1
Seats 3
through 6
Liszt
Row 2
Seats 1
through 7
Berlioz
Row 3
Seats 1
through 3

WAITING LIST:

empty


x
x
x


x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x



SEATING PLAN:

3
2
1
1 2 3 4 5 6 7

SUBMISSION 

No 'user friendly' interface is expected for this assignment. Your submission should, however, include evidence of your design process. Your hardcopy submission should include detailed design information consisting of UML class diagrams, module definition in high level pseudocode, algorithm design presented in pseudocode, and associated data structures, as well as your final source code.


Write your application in such a way that the method main() is located in a file named Theatre.java. Ensure that it is possible to run the application by redirecting the input/output from/to a file specified on the command line, ie.


javaTheatre<infile>outfile

You should strive for a clean and simple programming style. Your program must contain appropriate brief identification and comments. In particular, include your name, subject, assignment, date written, assumptions made and a brief description of the program at the start of the program. At the start of each class and method there should be a comment clearly and completely describing what the function does.
Marks will be awarded on the basis of your design, the program's correctness, clarity, use of comments, completeness and efficiency.

6 comments:

  1. Get Assignment help from the expert. Java Assignment help,just question answer is one of the best online homework market place, where you can tutor for any subject

    ReplyDelete
  2. Vitalbrands, starting for the best shopping knowledge in our property, is the first and greatest web based shopping site in Pakistan devoted to streak deals. As a scaffold amongst Pakistan and China and Many Others Countries, Vitalbrands brings the best items into Pakistan from both the nearby and worldwide markets. With us encounter the liveliest and least demanding internet shopping background in the most bother free route in Pakistan. Since our venture into Pakistan in 2011, our shopping gateway has recorded exponential development. Energizing arrangements at fantastically costs are offered each day, with rebates coming to up 90%! https://vitalbrands.pk/

    ReplyDelete

Entries RSS Comments RSS

Sample Text

Pages


Copyright © Lovely Codes
Powered by Blogger
Distributed By Free Blogger Templates | Design by N.Design Studio
Blogger Theme by Lasantha - PremiumBloggerTemplates.com