CIS 220 - Program 7
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 "The Mousetrap." (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. 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, _
Add this line at the beginning of your program, BEFORE any other lines:
For full credit, DO NOT use global variables. You may use static 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.