Hi,
I am working on a project that requires a dynamic array and I am not sure how to create this array. I have created the whole project skeleton and works okay, but now I need to add the array.
If you look under the rules. There is always a list to be printed containing "Plane name, Name of Party and Number of people in the party".
Please look the "bold" text on each of the rules. As far I understand, this list must be kept with all records entered;so , I can print from it when one of the rules is true. Once one of the planes "fly", the records for that plane should be deleted from the array/table.
Again, I got the program running, but it's not keeping the record of parties names and how many in the party to be displayed when one of the rules is true.
Here is the text of the project;
--------------------------------
Your employer has determined a market for a simple airline ticketing system for a very simple airline. The airline only has two aircraft, named ALFA and BRAVO. Initially, the ticket system will determine the number of seats on each plane and in the lounge. The ticketing system is to be installed at the airport ticket booth for the airline and will operate under the following rules:
.
1) If a party arrives and there is enough room on the plane requested, they are allowed to board and a message to that effect is printed.
.
2) If a party arrives and there is not enough room on the plane requested due to people already being on the plane, the party is directed to wait in the lounge and a message to that effect is printed.
.
3) If a party arrives and there is not enough room on the plane requested because the plane is just too small, the party is turned away and a message to that effect is printed.
.
4) If a party is directed to the lounge and there is not enough room in the lounge, the party is turned away.
.
5) Parties are never split.
.
6) A plane will fly whenever it becomes full and a list of all parties on board will be printed.
.
7) A plane may fly upon a command from the ticket clerk. Again a list of all parties on board will be printed.
8) The ticket clerk will enter when a plane flys and upon the return of the plane the system will move people from the lounge to the plane in the order in which the parties arrived, but will skip parties that cannot fit and search for those which can fit. A list of those parties boarding the plane will be printed.
.
9) When the airline shuts down for the night, the airplanes will continue to fly and return (without the ticket clerk performing any action) until all parties in the lounge have flown with appropriate messages being printed.
.
10) Party names do not have a maximum size.
I have asked the professor more about it and he wrote me back saying:
====================================================================
You can dynamically create a one dimensional array of structures. In database terms, a table consisting of multiple records,
each record having multiple fields. You only have one entry per party but part of that structure (a field of the record) contains
the number of people in the party. You need to keep track of how many parties are on the plane so you know which slot is empty for
the next party. The number of seats is another piece of information you keep track of and update by the number of seats used (people in) the party.
Here are the structures in the program:
======================================
#ifndef PLANE_H
#define PLANE_H
#include "Party.h"
struct Plane
{
long MaxNumSeats;
long NumSeatsAvailable;
long HowManyParties;
Party * Who;
};
#endif
. . . . . . . . . . . . .
#ifndef PARTY_H
#define PARTY_H
enum Planes {Alfa, Bravo, Invalid};
struct Party
{
char * pName;
long HowMany;
Planes WhichPlane;
};
Sorry... I did not mean to ask to resolve my project, but thanks for your reply.
I just wanted to ask how to create the array/table based on my structures, but I will work my array/table based in your example. I will let you know...
PlaneAlfa.Who = new Party [Number];
PlaneBravo.Who = new Party [Number];
PlaneLounge.Who = new Party [Number];
The "Number is entered as part of the initalization......
Below I am initializating Alfa....
case ALFA:
if (AlfaInitialized == false)
{
//cout << "ALFAInitialized-1 :" << AlfaInitialized << endl;
cout << "Enter number of ALFA seats: ";
Number = ReadInteger (); // number entered will define maxseat, seatavailable
.
.
.
.
.
.
.
.
// Board Alfa plane, enter: name of party, How many in the party
if ((TempParty.HowMany <= PlaneAlfa.MaxNumSeats) && (TempParty.HowMany <= PlaneAlfa.NumSeatsAvailable)) //BoardPlaneAlfa
{
// HERE I need to create a the table to load name of party and howmany in the party
======================= I am not sure how to load the tables, print out and delete those records that flu in plane Alfa.... Can you guide me how to do that?
Do you have a specific question? If not, keep working until you do, or succeed.
You are already using tables, example: planeAlfa.Who[].
I do not understand what you need help with.