Your employer has determined a market for a simple bus loading system. The syste
ID: 3767219 • Letter: Y
Question
Your employer has determined a market for a simple bus loading system. The system only has two buses available, named BUS1 and BUS2. Initially, the loading system will ask the user for the number of seats on each bus and in the lounge (the lounge is where the bus passengers go to wait until they can load the bus). The loading system will operate under the following rules:
1) If a party arrives and there is enough room on the bus 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 bus requested due to people already being on the bus, 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 bus requested because the bus 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 bus will leave whenever it becomes full and a list of all parties on board will be printed.
7) A bus may leave upon a command from the loading clerk (the user). Again a list of all parties on board will be printed.
8) After a bus has left and printed out the list of parties on board, the system will move people from the lounge to the empty bus 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 bus will be printed.
9) When the bus loading system shuts down for the night, the buses will continue to depart and return (without the ticket clerk performing any action) until all parties in the lounge have departed with appropriate messages being printed.
10) Party names do not have a maximum size.
(use dynamic memory allocation/deletion)
The commands the system will accept are the following initialization commands:
BUS1 <size>
BUS2 <size>
LOUNGE <size>
Once the buses & lounge are initialized, the system will accept the following command:
ARRIVE <bus> <party> <size>
DEPART <bus>
SHUTDOWN
where: <bus> is either BUS1 or BUS2.
<party> is a name of unlimited length.
<size> is an integer number
Fields in the input will be separated by some amount of whitespace.
String Object and GOTOs are not allowed
Explanation / Answer
#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 {Bus 1, Bus 2, Invalid};
struct Party
{
char * pName;
long HowMany;
Planes WhichPlane;
};
#endif
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.