Theater Reservation System
Objectives: Gain experience using arrays.
Description: This program is intended to provide you with experience using one-dimensional arrays and static variables.
A small production company recently purchased a computer for its automated reservations system. Write a program to assign seats for each production of the mystery "While the Clock Ticked." (capacity: 18 seats). Note: In reality a theater will have more than 18 seats, but it gets tedious to test the program if 100 seats are allocated. Programmers often test a "scale model" of a program to be sure it works correctly before expanding it to the actual size. Judicious use of constants helps to make such a transition painless.
Your program should display two radio buttons on a panel to provide the following alternatives:
If the user selects "Reserved Seating," then the program should assign a seat in the reserved section (seats 1-6). If the user selects "General Admission," then the program should assign a seat in the general admission section (seats 7-18). The default should be "General Admission." Your program should display a ticket indicating the seat number and whether it is in reserved or general seating.
Use a one-dimensional Boolean array to represent the seating chart of the theater. Initialize all of the elements of the array to True to indicate that all the seats are available. As each seat is assigned, set the corresponding element of the array to False to indicate that the seat is no longer available. Use subs or functions to determine the next available general or reserved seat, subs or functions to book that general or reserved seat. Be sure that you pass an array or arrays as parameter(s) to at least one of the subs or functions. When determining the next available seat search through the array until you find it rather than relying on an external variable.
The program must never assign a seat that has already been assigned. When the Reserved Seating is full, your program should ask the person if it is acceptable to be placed in General Admission, and vice versa. If it is acceptable, then make the appropriate seat assignment. If it is not acceptable, then display the message "The next production is tomorrow night!" When the production is completely booked, an appropriate message should be displayed.
Use radio buttons for user input, a button to begin processing, a button to print a ticket, a button to exit the program, and a label to display the ticket. Be sure that your program design has strong cohesion and loose coupling. Message boxes can be used to display additional messages. Be sure to turn in a flowchart, pseudocode, or a structure chart. The primary interface is shown below.
To print a label (such as the ticket), you can use code like the sample below, obtained here. In this code, the label control used to display the ticket is called lblPass. Printing the label's text prints the viewable portion of the label.
Private Sub cmdPrint_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdPrint.Click
' The document you will use to print on
Dim DocPrint As New PrintDocument
' A handler for it
AddHandler DocPrint.PrintPage, AddressOf PrintThePage
' You can insert Optional code here to show PrintDialog and/or PrintPreview
' Print the document (layout instructions are written by the developer in
' the PrintThePage procedure below)
DocPrint.Print()End Sub Private Sub PrintThePage(ByVal sender As Object, _
ByVal e As PrintPageEventArgs)
' Set font and calculate line height for printing
Dim fnt As Font = New Font("Verdana", 12, FontStyle.Regular)
Dim printlineHeight As Single = fnt.GetHeight(e.Graphics)
'Set start Location for printing
Dim x As Single = 5
Dim y As Single = 65
' Draw/Print the text.
e.Graphics.DrawString(lblPass.Text, fnt, Brushes.Black, x, y)
Add this line at the beginning of your program, BEFORE any other lines:
For full credit, DO NOT use global variables. This program is intended to give you practice passing arrays as parameters. Be sure to use Subs and Functions and that they exhibit strong cohesion and loose coupling!!!!
Demo Note: The demo interface is enhanced to better show you how the program is working. You are not required to graphically display the theater seating as the demo does.
Bonus: The theater will hold three productions of "While the Clock Ticked" -- on April 6, April 13, and April 20. Allow theatergoers to make reservations for any of the three productions. Furthermore, if they attempt to book seats for a full production, it should give them the option of making reservations for the next production that has available seats.