I am having trouble figuring out a start off point for this project. Can anyone help me get started? I would really really appreciate it. I'll post the code and instructions below.

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 alphnumeric 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, 4D
5A, 5B, 5C, 5D
6A, 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 rich text box 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 rich text box 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 rich text box.

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;


Using the pseudo code below, write the code that will meet the requirements:

At the top of the form class declare the following:
bool activeFlight = true;
private string[] passNameAr = {"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "" };
private string[] seatAr = {"1A", "1B", "2A", "2B", "4A", "4B", "4C", "4D",
"5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B", "7C", "7D" };
private int numFirstClass = 0, numBusinessClass = 0;
private string[] flightClassAr = { "First", "Business" };

In the form constructor after InitializeComponent():
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

Recommended Answers

All 16 Replies

What kind of program are you supposed to write? Windows Forms? MFC? wxWindows? win32 api?

I assume by now you have been given enough instructions in class to complete this assignment. Or have you been sleeping in class?

In defense of Jutch, they really didn't go over any of the GUI stuff. I'm also taking C++ and this is kind of a sink or swim situation. They just kind of threw it in for the last week of class.

In defense of Jutch, they really didn't go over any of the GUI stuff. I'm also taking C++ and this is kind of a sink or swim situation. They just kind of threw it in for the last week of class.

I'm assuming you are in my class or taking the same online class as me?

What kind of program are you supposed to write? Windows Forms? MFC? wxWindows? win32 api?

I assume by now you have been given enough instructions in class to complete this assignment. Or have you been sleeping in class?

It is for C++ Visual Basic 2008

Taking the same class, however don't know if we are in the same class. Yes, I do take it online. The only advice I can offer you is to watch the live lecture over and over again. It will help you.

Taking the same class, however don't know if we are in the same class. Yes, I do take it online. The only advice I can offer you is to watch the live lecture over and over again. It will help you.

I am. I wish it was helping me out more.

It is for C++ Visual Basic 2008

There is no such thing as c++ VB 2008. C++ and VB are two different languages.

It's MicroSoft Visual C++ 2008 Express Edition that the class requires us to use

Start out by creating a CLR Windows Forms project. That will generate the basic
dialog box on which you can drag&drop controls, such as edit and list boxes. Once you have the dialog visually set up the way you want it you can double-click a control and the IDE will create a startup event handler function for you. Then all you have to do is add your code in those event handlers.

CLR/C++ is not the same as c++ and you will have to learn some additional statemeents about .NET.

Closer look at this program and I see that it can be quite complicated for a new programmer. Unless you are using a textbook specifically about CLR/C++ you will have to do lots of research online, learning how to search through Windows::Forms and its controls.

I would be most surprised if this was an assignment for a first year c++ programming student. It has to be a Windows Forms class you are taking. Give yourself lots and lots of time to complete this assignment, doing only a small part at a time.

It is for a Introduction to Programming C++ and none of this was covered by the professors of the course( the online live lecture professor told us herself). They introduced it to us last week and then sprung this huge program on us this week(the last week of class) and expect us to know what to do.

Yeah. I am in the same course through Devry Online. Same problem. We don't even get live lecture help until Thursdays. GUI stuff isn't even in out text, and they want us to do it. This is my second attempt at this class, and we are required to get a 70 percent, and I'm just barely winging it with a 76% now. Plus we got finals on Thursday and assignment is due tonight at midnight. Thanks Devry for screwing us in our first c++ class ever!!!!

okay..so im taking it as we need 3 arrays labeled as

passNameAr[]
seatAr[]
flightClassAr[]

and from the pseudocode 5 functions labeled as
initializeComponent()
displayManifest()
assignSeat()
populateSeatCombo()
displayPassengerList()

I did really lousy in the array lab, so I am just dumbfound on that to begin with. When I asked instructor to explain to me where I went wrong all he could give me was vague answers..even asked for an answer key or example so i could actually see what it should look like, and he never game me one. So yeah..its like..here's your crappy grade..have fun using arrays for the rest of the session!

I don't even know where to place this bit...ahhh..i hate this!!!

At the top of the form class declare the following:

bool activeFlight = true;
private string[] passNameAr = {"", "", "", "", "", "", "", "",
    "", "", "", "", "", "", "", "", "", "", "", "" };
private string[] seatAr = {"1A", "1B", "2A", "2B", "4A", "4B", "4C", "4D",
    "5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B", "7C", "7D" };
private int numFirstClass = 0, numBusinessClass = 0;
private string[] flightClassAr = { "First", "Business" };

watch the live lecture and download the files. She gave us a whole new code to work from and showed us where to put certain stuff. That original is written for a C# program. And yes those are the arrays you will need minus the brackets

That situation really sucks :( I'd certainly ask your lecturer why he/she assigned a program that has to be written in CLR/C++ Windows Forms, CLR/C++ is not the same as standard c++ and would require a totally different and more advanced class.

For starters, you will want to read some of these links to find out how arrays work in CLR/C++. For example to declare an array it would be like this:

array<String^>^ Seats = gcnew array<String^> {"1A","1B","2A","2B",
                "4A","4B","4C","4D",
                "5A","5B","5C","5D",
                "6A","6B","6C","6D",
                "7A","7B","7C","7D"
            };
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.