You are on page 1of 8

HELPIDO.

COM

CIS 170 iLab 7 of 7
CLICK HERE TO GET THE TUTORIAL !!!!!!!

Step 1: Requirements - Airline Reservation System
Bluebird Airlines needs a program to assign boarding passes on its only plane which has a seating
capacity of 20. They want to use an alphanumeric seat number, and they want to be able to assign a
passenger to a specific seat within either first or business class. The seats in the plane are numbered as
follows:
FIRST CLASS BUSINESS CLASS
1A, 1B, 2A, 2B 4A, 4B, 4C, 4D5A, 5B, 5C, 5D6A, 6B, 6C, 6D
7A, 7B, 7C, 7D

The first 4 seats are first class and the remaining 16 are business class. Store the seating information in
arrays. One array for the seat number and another array for the passenger’s name. You will need to
hard code the seat number array and set every element of the passenger array to blanks. If a seat is
empty, the corresponding array element is blank. If a seat is reserved, the corresponding array element
has someone’s name in it. Display the Plane Manifest in a ListBox at the bottom of the window form.

The program should prompt the user to enter the passenger’s name, select the class of the ticket (First
or Business), and select the seat number. The windows form will have a text box to input the
passenger’s name; two combo boxes: flight class and seat number; two buttons: Add Passenger and
Close Flight; and a listbox control to display the plane manifest. The ComboBoxes need to have a
DropDownStyle of DropDownList. You will populate the seat number combo box with the available
seats of the class selected. You will need an event handler for the class combo box that indicates when
the user has changed the class. Depending on the class selected, you will populate the seat number
combo box with the available seats for that class.

The user will enter the passenger’s name, select the flight class, and the seat number and press the Add
Passenger button. The program will validate the data in the fields. The passenger’s name must not be
left blank; otherwise, a MessageBox will be displayed indicating the error and the user will be returned
to the passenger’s name text box. If the seat is left blank, display an error message and return to the
seat number. If everything is ok, assign the passenger to the seat, update the Plane Manifest, clear the
name field, set the class back to First, and the seats back to available first class seats, and return the user
to the passenger name field.

Once the plane is full, disable the Add Passenger button. The user will then need to close the flight.

Even though the plane is not full, the user may close the flight by pressing the Close Flight button.
Disable the Add Passenger button and change the text in the Close Flight button to Start a New Flight. In
the listbox control in addition to displaying the Plane Manifest, display the number of first class
passengers and business class passengers, and a passenger list. The passenger list is in alphabetical
order by passenger name. Only display assigned seats in the passenger list. You will need to sort the
data into alphabetical order by passenger name to display the passenger list. Also write these reports to
a text file.

When the user clicks the Start a New Flight button, change the button back to Close Flight, enable the
Add Passenger button, and clear the passenger name array and the fields on the screen. An empty
Plane Manifest should be displayed in the listbox control.

If the user double clicks an entry in the list box, delete that passenger from the seat.

For the 2 Combo Boxes in this application make the DropDownStyle a DropDownList.

Do not do all of the work in the button event handlers. Write other methods that are called from the
event handlers to do the work.

Hints:

To load the data in the flight class combo box, set up an array and set the combo box DataSource to the
array reference.

// defined as an attribute value of the form class
private string[] flightClassAr = {“First”, “Business”};
// Done in the form constructor after InitializeComponent()
FlightClassComboBox.DataSource = flightClassAr;

Step 2: Processing Logic
Using the pseudo code below, write the code that will meet the requirements:At the top of the form
class declare the following:

Boolean activeFlight
An array of string for passNameAr
An array of string for seatAr
An array of string for flightClassAr

In the form constructor after InitializeComponent():

Initialize the passNameAr to all empty strings
Initialize the seatAr to {“1A”, “1B”, “2A”, “2B”, “4A”, “4B”, “4C”, “4D”,
“5A”, “5B”, “5C”, “5D”, “6A”, “6B”, “6C”, “6D”, “7A”, “7B”, “7C”, “7D” }
Initialize the flightClassAr to { “First”, “Business” };
Assign true to activeFlight
Assign 0 to numFirstClass
Assign 0 to numBusinessClass
Set the flight class combo box data source to the flight class array
Clear the seat number combo box and dynamically populate it with the first
class seats
Set the seat number combo box’s selected index to 0
Call the DisplayManifest() method

In the Add Passenger button click event handler:
Ensure that the name was not left blank.
Locate the index position of the seat in the seat array.
Call the AssignSeat() method passing it the passenger name, flight class
and seat index
Call the DisplayManifest() method.
Call the PopulateSeatCombo() method.

In the Close Flight button click event handler:
If the flight is active
Call the DisplayManifest() method
Call the DisplayPassengerList() method
Set the text of the Close Flight button to “Start a New Flight”;
Set activeFlight to false
Make the Close Flight button the control of focus
Disable the Add Passenger button
Else
Set the text of the Close Flight button to “Close Flight”;
Enable the Add Passenger button
Blank out the passenger name array
Sort the seat array in ascending order.
Clear the seat number combo box and dynamically populate it with
the first class seats
Set the seat number combo box’s selected index to 0
Reinitialize first class and business class counters
Call the DisplayManifest() method
Set activeFlight to true
Make the Passenger Name text box the control of focus

Flight Class combo box selected index changed event handler:
If the user selected first class
Dynamically populate the seat number combo box with the available
first class seats
Else
Dynamically populate the seat number combo box with the available
business class seats
Set the Seat Number combo box’s selected index to 0

Plane Manifest list box double click event handler:
If the user clicked on a seat
If a passenger is assigned to the seat
Prompt the user if she wants to remove the passenger from the seat
If the user says yes
Delete the passenger’s name from the array.
Subtract 1 from the appropriate seat counter
Call the PopulateSeatCombo() method
Call the DisplayManifest() method

DisplayPassengerList() method
Sort the arrays in passenger name order
Display the number of first and business class passengers in the list box
Display the passenger list in the list box

DisplayManifest() method:
Clear the list box
Write the plane manifest to the list box

AssignSeat() method:
Assign the passenger’s name to the passenger name array.
Add 1 to the first class or business class seat counter depending
on the flight class

PopulateSeatCombo() method:
Blank out the Passenger Name text box
Repopulate the flight class array with both flight classes
Set the Flight Class combo box data source to the flight class array
Set the Flight Class combo box’s selected index to 0
Clear the Seat Number combo box
If all the seats are occupied
Set the focus to the Close Flight button
Disable the Add Passenger button
Exit the method

Set the focus to the Passenger Name text box
If there are first class seats available
Populate the Seat Number combo box with the available first class seats
If all the business class seats are full
Populate the flight class array with just First
Set the Flight Class combo box data source to the flight class array
Else
Populate the Seat Number combo box with the available business class seats
If all the first class seats are full
Populate the flight class array with just Business
Set the Flight Class combo box data source to the flight class array

Step 3: Create a new project
Create a new project and name it LAB7.Write your code using the Processing Logic in Step 2. Make sure
you save your program.
Step 4: Compile and Execute
a) Compile your program. Eliminate all syntax errors.b) Build your program and verify the results of
the program. Make corrections to the program logic if necessary until the results of the program
execution are what you expect.

Step 5: Print Screen Shots and Program

1. Capture a screen print of your output [Do a PRINT SCREEN and paste into an MS Word document.]
2. Copy your code and Paste it into the same MS Word document that contains the screen print of
your output.
3. Save the Word Document as Lab07_LastName_FirstInitial

END OF LAB