Objectives: Create structures to hold multiple pieces of data. Utilize pointers for more efficient memory allocation.
Problem: In preparation for the release of Guardians of the Galaxy 2, you have been hired by the owner of a small movie theater to develop the backend for an online ticket reservation system. Patrons will be able to reserve seats in one of three auditoriums. Once the patron has selected an auditorium, the program should display the current seating arrangement and allow the patron to select seats. A report should be generated at the end of the program to specify for each individual auditorium and overall for all auditoriums how many seats were sold/unsold and how much money was earned.
Details (Changes from project 1 are displayed in blue)
- The seating arrangement for each auditorium will be stored in separate files. These files will be named A1.txt, A2.txt and A3.txt for auditorium 1, 2 and 3 respectively.
- Each line in the file will represent a row in the auditorium. The number of rows in each auditorium is unknown to you.
- The number of seats in each row of a single auditorium will be the same. For example, if the first line of the file has 15 seats, then every subsequent row in the theater will also have 15 seats. This does not mean that each auditorium has the same number of seats in each row. One auditorium may have 15 seats per row and another may have 20 seats.
- Empty seats are represented by a pound sign (#).
- Reserved seats are represented by a period (.).
- Each file should be read into memory and stored in a linked list
- For each auditorium, you will have 2 linked lists one for reserved seats and one for available seats
- When available seats are reserved, the nodes from the available list should be moved into the reserved list
- Both lists should be sorted by row and seat number all row 1 seats grouped together in order by seat, then row 2, etc.
- If the user is reserving seats, ask the user for the number of tickets, the row and seat number of the first seat. If that seat and all seats to the right of it (up to the number of tickets desired) are available, move the nodes from the available linked list into the reserved linked list.
- EXTRA CREDIT
- If the desired seats are not available, offer the user the best available seats that meet their criteria on that row only. The best available seats are the seats closest to the middle of the row.
- First check if the pure middle is available
- If not, measure the closest to the middle by the end points of the selection.
- For the left side of the auditorium, find the distance between the middle and the right endpoint
- For the right side of the auditorium find the distance between the middle and the left endpoint
- If the user declines the best available seats for that row, return the user to the main menu.
- If the user accepts the best available seats for that row, reserve them.
- Tickets can only be reserved the day of the screening and all screenings are at 7 PM that night. There is no need to worry about multiple screenings or reserving seats on a specific day.
- All tickets are $7 regardless of patron age or auditorium.
- Once seats are chosen by the user, update the file.
- At the end of the program, overwrite the original files with the new information
Linked List Node
- Each node represents a seat
- The node will consist of three items:
- Row number
- Seat number
- A pointer to the next node in the list
- Each node is created dynamically and should be filled immediately after being created
- Putting the node in the proper list (available or reserved) should help mark the status of that seat
- If you feel another member is necessary to mark the status you may add it in
User Interface and Input: Present a user-friendly menu system for the user to reserve seats. First ask for the auditorium:
1. Reserve Seats
2. View Auditorium
3. Ticket Report
4. Exit
Although in reality the user would likely only make one purchase, for testing purposes, assume the user will repeat the ticket buying process until they decide to quit.
After the user has selected a non-exit option, present the user with a menu to select the auditorium.
1. Auditorium 1
2. Auditorium 2
3. Auditorium 3
Once the auditorium has been selected, display the current seating availability for that auditorium. An example seating chart is provided below for an auditorium with 5 rows and 20 seats per row.
12345678901234567890
1 ...##..#####........
2 ########....####..##
3 .........##.........
4 #.#.#.#.#.#.#.#.#.#.
5 ########.#####.#####
The seats are numbered sequentially from left to right and only the ones digit is displayed above each column to make it easier to display the chart. It is understood that the second set of digits from 1-0 are for the numbers 11- 20 in the above example.
After the user has selected the auditorium and the seating chart has been displayed, prompt the user to enter the number of tickets and then prompt the user for the first seat to reserve. You may prompt the user for the row and seat number of the first seat. Assume that the user wants to reserve sequential seats to the right of the first seat entered.
All input will be of the valid data type. You do not have to worry about the user entering a letter when a number is expected or a floating point number when an integer is expected. You are responsible for validating that the data falls within the proper range and that a user does not try to reserve a seat that is already reserved.
User Interface Workflow: To minimize the problems that were introduced between project 1 and the batch run application, please follow this workflow for your interface. Please do not add extra prompts since this will cause a mismatch in the input which will either force the program to throw an exception or cause the program to perform an unintended operation.
- Display main menu
- Prompt for input
- Display auditorium menu (if selection is not exit)
- Prompt for input
- If user is reserving tickets
- Prompt for row
- Validate loop until valid
- Valid row = row number listed in auditorium display
- Prompt for seat
- Validate loop until valid
- Valid seat = seat number listed in auditorium display
- Prompt for number of tickets
- Validate loop until valid
- Valid ticket number = number >= 0
- EXTRA CREDIT AREA DO NOT ADD UNLESS YOU CODE THE EXTRA CREDIT
- If seats unavailable display best available selection
- Prompt user to reserve (Y/N)
- ALL PROGRAMS MUST INCLUDE A PROMPT ASKING USER TO RESERVE BEST AVAILABLE
- If you DO NOT develop the logic for the extra credit (best available), capture the input from the user and move to the next item in the workflow confirming if a reservation happened
- If you DO develop the logic for best available, reserve the seats if the user enters Y and move to the next item in the workflow confirming the reservation.
- If reserved, confirm reservation
- Return to main menu
- If user wants to see auditorium
- Display auditorium
- Return to main menu
- If user wants to see report
- Display report
- Return to main menu
- Loop to top of workflow until user selects exit
Output: Display a message to let the user know if the seats were reserved or if the seats are not available.
At the end of the program, display a formatted report to the console. The report should consist of 4 columns:
- Column 1 labels
- Auditorium 1
- Auditorium 2
- Auditorium 3
- Total
- Column 2 - number of all seats reserved for each label
- Column 3 - the number of all open seats for each label
- Column 4 - the overall total of the ticket sales for each label