Assignment 10
Due: Wednesday, December 4, 2013

WebCAT is ready for submissions
--------------------------------

Implementing Ticket Seller application

Minimum from Assignment 9:
--------------------------
“At the minimum you should allow for several theaters 
within the complex, at least three ticket price categories, 
at least three time slots per theater, at least five 
different movies shown.” Initialization file will have 
at least three theaters, at least three ticket prices, 
at least three time slots per theater, and at least five 
movies.

You should design your own way of initializing the cinema
information for one day of shows, handling the interactions 
with the ticket sales office and with the manager. 

Important: 
----------
If your program uses a GUI for use interactions 
in any way, you have to make sure the GUI is not opened
when the program tests are run, or when the program 
responds to our requests for initialization, sales, and 
reports. Add a README.txt file where you explain how the
GUI interactions can be run.

Additionally, so we can test your program, your program 
should include a class TicketSales that contains
the following methods:

void initCinema(String fileName)
void processOrders(String fileName)
String reportSales()
String managerReport()
String logReport()

Initializing the cinema data:
-----------------------------

To test your application we will provide the initial data 
for the cinema complex. We will do this by invoking the 
method initCinema(fileName), providing the name of the file
that contains the initialization data.

Your application should be able to read the file that 
initializes the cinema complex schedule for any given day. 

A sample input file 'cinema.txt' is provided.
(Course directory: /course/cs3500f13/Assignments/A10)

The file that provides the initial information will be 
formatted as follows:

Movies
Harry Potter:102
Great Expectations:115
...
Theaters
A:300
B:90
C:500
...
Shows
1,1,960
1,1,1080
1,1,1200
1,3,1020
1,3,1140
2,2,990
2,2,1210
...
Prices
Adult:10
Child:7
Senior:8
...
End

The headings “Movies”, “Theaters”, “Shows”, and “Prices” 
will signal the change in type of data and "End" will 
indicate the end of input.

The format of this file is designed so that it can be 
generated by the user's input from a console or user's 
input from some GUI. That way the main program that manages 
the sales can be initialized by using several different 
sources of information - enforcing the model (sales 
processing) and view (user's input) separation. 

The ... indicates that there could be additional entries 
of the same type. Each entry is on a separate line. 

This cinema complex is showing two movies, Harry Potter that 
runs for 102 minutes and Great Expectations that runs for 
115 minutes. The delimiter separating the movie title from
the duration is a colon (:) - allowing for movie titles with 
commas.

The cinema complex has three theaters named 
A, B, and C with seating capacity of 300, 90, and 500 
respectively. The delimiter separating the theater name from
the capacity is a colon (:) - allowing for theater names with 
commas.

There are three showings of Harry Potter 
(movie 1 in the list) in Theater A (theater 1 in the list) 
the first one at 4:00 pm (960 minutes), the second at 6:00 pm 
and the third at 8:00 pm. Harry Potter is also playing in 
Theater C at 5:00 pm and at 7:00 pm. Great Expectations is 
shown in Theater B at 4:30 pm and at 6:30 pm. The entries 
for this section are all integers, separated by a comma, 
with no spaces allowed, one line per show.

The prices are always given in whole dollars, adults pay $10, 
children pay $7, and seniors pay $8. The delimiter separating 
the price category from the price is a colon (:).

Your programs has to include the option of initializing the 
data from a file like this, and from at least one other 
source (a GUI or a console). The input from the other source 
should first generate a sequence of String-s in the same 
format as given here - and the initialization should then 
process both sources in a uniform manner. Whether you choose 
to allow users to input from a GUI or a console, you need to 
make sure that the implementation is robust---provides 
prompts, checks for errors, handles incorrect input 
gracefully, etc. If you detect an error or inconsistency in 
the input data, ignore the offending line, and add
a message to the log (one line per message) that describes
the problem (e.g. "Unknown movie in request ...");

Specifically, if a given show is in conflict with shows 
already scheduled, it should be ignored (not added to the 
total cinema data base) and a report should be added to the
log file (and, perhaps, also printed to the console).

Selling tickets, reporting on sales:
------------------------------------

Once your program reads this file (or console or GUI) 
our program will invoke the method processOrders(fileName) 
providing the name of the file that contains the series
of ticket sales requests,and requests for the manager's 
reports on the status of the sales. Your program should 
respond to movie-goers' orders and at any time process 
the manager's request on the status of the sales.

Again, we specify the format of the sales requests and manager's 
requests for reports that you must use. These requests will come 
in a separate file that your program should read. Additionally, 
your program should provide at least one other way that the sales 
requests and the report requests can be generated (GUI or console) 
and these requests should be presented to the program that 
processes the sales in this format, regardless of the source 
from which the requests were issued. 
 
A sample input file 'orders.txt' is provided.
(Course directory: /course/cs3500f13/Assignments/A10)

We repeat: Whether you choose to allow users to input from a GUI 
or a console, you need to make sure that the implementation 
is robust---provides prompts, checks for errors, handles 
incorrect input gracefully, etc.

The responses to the orders should be saved to sales report,
that is a String with one line per order. Each line should 
contain the original request followed by a comma and the price 
of all tickets in the order. If the order cannot be processed 
(either because it did not specify valid show or because the show 
is sold out) the price should be reported as zero.

The responses to the manager's update request will also go to a 
manager's report separate from the order responses. 
For each manager's request the first line of the report will be

Report x

where x is the report number (starting at 1, incremented for 
each request). Each of the following lines will report on sales 
for one showing of the movie in a specific theater 
at a specific time. The format is given below.
Of course, you will also report 
these to the manager via a GUI or a console, but that is your
design contribution.

The sales orders and the manager's requests will be co-mingled 
in one file, as the manager may want to know at 6:00 pm, what had 
happened up until now, and get a final update at the end of the 
day as well.

The order request will be in the following format:

1,1,960,2,3,0
2,2,990,3,0,2

where the first order is for 2 adults and 3 children to see 
Harry Porter at 4:00 pm in Theater A, the second order is 
for 3 adults and 2 seniors to see Great Expectations in 
Theater B at 6:30 pm.

The response is the total price for all tickets, if there 
are sufficient number of tickets available or zero, if 
the show is sold out or there are not enough seats 
for all members of the party. For the above two orders, if
the shows are not sold out, the order report would be:

1,1,960,2,3,0,41
2,2,990,3,0,2,46

At any time the sequence of order requests may be interrupted 
by a manager's request for status. This request will be very 
simple, consisting of a single word:

report

with no additional information given. The program should report 
the status as in a csv format as follows:

Report 2
1,1,960,150,85,15,50  
1,1,1080,120,100,10,70
1,1,1200, ...
1,3,1020, ...
1,3,1140, ...
2,2,990,50,0,35,5
2, 2, 1210, ...

indicating that we have sold 150 adult tickets, 85 children 
tickets, and 15 senior tickets for the first showing of Harry 
Potter in Theater A with 50 empty seats, ... and 50 adult 
and 35 senior tickets for Great Expectations in Theater B 
at 6:30 pm, with 5 empty seats, one line per entry, with the 
header specified earlier.

Example file with sales orders and the manager's requests 
co-mingled in single file: 

1,1,960,20,30,40
1,1,960,30,20,50
1,1,960,40,30,50
report
1,3,1020,20,10,30
2,2,990,20,40,20
2,2,990,10,5,10
report

Your own report to the manager should use the data generated 
in response to the "Status Update" and provide humanly readable, 
understandable summaries.

Generating reports
------------------

The reports - error log, sales processing, and manager's reports
shall be saved by your program until the user requests them.

Out program will request these reports by invoking the methods:

String reportSales()
String managerReport()
String logReport()

in your TicketSales class. We will run tests that will compare your
results with ours. For the reportSales and managerReport your
output should correspond to our expected results. The logReport
should have the correct number of lines, but their contents
is up to you.

Our tests will be in the following format:

class TicketSalesTest {
	...

    public static void main(String[] argv) {
        TicketSales prog = new TicketSales();
        prog.initCinema("cinema.txt");
        prog.processOrders("orders.txt");
        String sales = prog.reportSales();
        String manager = prog.managerReport();
        String log = prog.logReport();

        tests that verify the sales, manager, and log results 
    }

}

The WebCAT server for the assignment will be ready by 
Wednesday evening.

——————————————————————————————————————————————————————

Collaboration between students is forbidden on this 
assignment. You are responsible for keeping your code 
hidden from all other students. You will submit this 
assignment within Web-CAT.

Your files of Java code should begin with a block comment 
that lists:
    1.  Your name, as you want the instructor to write it.
    2.  Your email address.
    3.  Any remarks that you wish to make to the instructor.

Part of your grade will depend on the quality and 
correctness of your code, part will assess the tests you 
design - especially the test coverage, part will depend on 
the readability of your code (comments and indentation), 
and part will depend on how well you follow the procedure 
above for submitting your work. Assignments submitted 
between 12:00 am and 11:59 pm the day after the due date 
will receive a 20 percentage point penalty on the assignment. 

For this assignment, you will submit the following:
 - Your code for the Ticket Seller application.
 - Your requirements document and design document with any 
     updates. If there are updates to these documents, you 
     should note why the changes were made.