Clues: Theater Program

 

Remember the principles of cohesion and coupling.  Your subs and functions should perform a single task only, and communication should be restricted to the parameter list. Use simple functions like reservedSeatIsAvailable, bookReservedSeat, and generalSeatIsOkay.


Be sure that General Admission is the default.  If you do not specify a default and the user clicks the Make Reservation button, your program may enter an infinite loop.


Here is a code fragment showing the message box syntax as well as one of the VB constants that you can use:

Dim answer As Integer

answer = MsgBox("No reserved seats are available.  Would you like a seat in general admission?", (vbYesNo))
                :
If answer = vbYes Then
                 :
                 :

The final clue should be examined only when you get almost finished with the program and need help putting the customer in General if Reserved is full, and vice versa.  Make sure everything else is working first.  Student feedback indicates that if you look at it any sooner it may confuse you.   

This clue provides help with presenting alternatives when one option becomes unavailable, but use it ONLY if you become stumped and are unable to solve the problem on your own.   CLUE


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

CLUE:

In our scenario the user has two options, but one of those options may become unavailable at some point in time.  In such a case they must be offered the other option.  They can either accept or reject that alternative.  The code for this can seem complex, so here is an example.  Don't just read it and use it--BE SURE that you understand how and why it works!

 

noSelectionMade = True
While noSelectionMade
     Select Case True
          Case opt1.Value
               If option1IsAvailable Then
                    takeOption1 
                    noSelectionMade = False    ' made selection, so stop
               ElseIf option2IsOkay Then
                    opt2.Value = True                   ' don't try to do anything, just "select" the other
               Else
                    noSelectionMade = False     ' selected NOT to take the alternative, so stop
               End If
           Case opt2.Value
               If option2IsAvailable Then
                    takeOption2
                    noSelectionMade = False    ' made selection, so stop
               ElseIf option1IsOkay Then
                    opt1.Value = True                   ' don't try to do anything, just "select" the other
               Else
                    noSelectionMade = False     ' selected NOT to take the alternative, so stop
               End If
     End Select
End While