Please need ur help

closed account (2A7X92yv)
I have done most of my Homework --- but i need to finish it by today.. and i dont get few of the stuff.. Can any one please help.. so i can finish up the things that i dont get ..

This is my project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Your employer has determined a market for a simple airline ticketing system for a very simple airline (Tree Top Airways - TTA). 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.

 
The commands the system will accept are the following:

ALFA		<size>
BRAVO	<size>
LOUNGE	<size>
FLY		<airplane>
ARRIVE	<airplane> <party> <size>
SHUTDOWN

where:	<airplane> is either ALFA or BRAVO.
		<party> is a name of unlimited length.
		<size> is an integer number


This is what i have done, Most of it is.. done.. some i really dont get :

plane.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef PLANE_H
#define PLANE_H

#include "Party.h"

struct Plane
	{
	long	NumSeats;
	long	NumEmptySeats;
	long	NumParties;
	Party *	pParty;
	char	PlaneAbbrev;
	};

#endif 


ReadFunctions.ccp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#include <iostream>

using namespace std;

#include <conio.h>
#include <ctype.h>	// could use <cctype>
#include <math.h>	// could use <cmath>

#include "ReadFunctions.h"

static void BackSpace ()	// static means this function can only be used by other functions in this file
	{
	_putch ('\b');
	_putch (' ');
	}

double ReadDouble ()
	{
	char	c;
	bool	Digits		(false);
	int		Fraction	(0);
	double	Num			(0.0);
	int		Sign		(0);

	while (!isspace (c = static_cast <char> (_getch ())))
		{
		switch (c)
			{
			case '+':
			case '-':
				if ((Sign == 0) && !Digits)
						if (c == '+')
								Sign = 1;
							else  // c == '-'
								Sign = -1;
					else
						c = '\a';
				break;
			case '.':
				if (Fraction == 0)
						Fraction = 1;
					else
						c = '\a';
				break;
			case '\b':
				if (Fraction > 0)
						{
						BackSpace ();
						Fraction /= 10;
						if (Fraction > 0)
								{
								Num = static_cast <int> (Num * Fraction);
								Num /= Fraction;
								}
							else;
						}
					else
						if (Digits)
								{
								BackSpace ();
								Num = static_cast <int> (Num) / 10;
								if (Num == 0.0)
										Digits = false;
									else;
								}
							else
								if (Sign != 0)
										{
										BackSpace ();
										Sign = 0;
										}
									else
										c = '\a';
				break;
			case '0':
				if (!Digits && (Fraction == 0))	// doesn't do leading zeros
						{
						c = '\a';
						break;
						}
					else;
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				Digits = true;
				if (Fraction > 0)
						{
						Fraction *= 10;
						Num = Num + ((c - '0') / static_cast <double> (Fraction));
						}
					else
						Num = (Num * 10.0) + (c - '0');
				break;
			default:
				c = '\a';
			}
		_putch (c);
		}
	if (c == '\r')
			c = '\n';
		else;
	_putch (c);
	if (Sign < 0)
			Num = -Num;
		else;
	return Num;
	}


// this has been changed to work with cin

int ReadInteger ()
	{
	char	c;
	bool	Digits	(false);
	int		Num		(0);
	int		Sign	(0);

//	while (!isspace (c = static_cast <char> (_getch ())))
	while (!isspace (c = static_cast <char> (cin.get ())))
		{
		switch (c)
			{
			case '+':
			case '-':
				if ((Sign == 0) && !Digits)
						if (c == '+')
								Sign = 1;
							else  // c == '-'
								Sign = -1;
					else
						c = '\a';
				break;
			case '\b':
				if (Digits)
						{
						BackSpace ();
						Num /= 10;
						if (Num == 0)
								Digits = false;
							else;
						}
					else
						if (Sign != 0)
								{
								BackSpace ();
								Sign = 0;
								}
							else
								c = '\a';
				break;
			case '0':
				if (!Digits)
						{
						c = '\a';
						break;
						}
					else;
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				Digits = true;
				Num = (Num * 10) + (c - '0');
				break;
			default:
				c = '\a';
			}
//		_putch (c);
		}
	if (c == '\r')
			c = '\n';
		else;
//	_putch (c);
	if (Sign < 0)
			Num = -Num;
		else;
	return Num;
	}

UINT ReadHex ()
	{
	char	c;
	bool	Digits	(false);
	UINT	Num		(0);

	while (!isspace (c = static_cast <char> (_getch ())))
		{
		switch (c)
			{
			case '\b':
				if (Digits)
						{
						BackSpace ();
						Num /= 16;
						if (Num == 0)
								Digits = false;
							else;
						}
					else
						c = '\a';
				break;
			case '0':
				if (!Digits)
						{
						c = '\a';
						break;
						}
					else;
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				Digits = true;
				Num = (Num * 16) + (c - '0');
				break;
			case 'a':
			case 'b':
			case 'c':
			case 'd':
			case 'e':
			case 'f':
				Digits = true;
				Num = (Num * 16) + (c - 'a') + 10;
				break;
			case 'A':
			case 'B':
			case 'C':
			case 'D':
			case 'E':
			case 'F':
				Digits = true;
				Num = (Num * 16) + (c - 'A') + 10;
				break;
			default:
				c = '\a';
			}
		_putch (c);
		}
	if (c == '\r')
			c = '\n';
		else;
	_putch (c);
	return Num;
	}

ReadString.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>

using namespace std;

#include <ctype.h>
#include <memory.h>

#include "ReadString.h"

char * ReadString ()
	{
	const	long	StartingSize (50);
			long	CurrentNumChars;
			long	CurrentSize;
			char *	pStr;
			char	c;

	CurrentSize		= StartingSize;
	pStr			= new char [CurrentSize + 1];
	CurrentNumChars	= 0;

	while (!isspace (c = cin.get ()))
		{
		pStr [CurrentNumChars++] = c;
		if (CurrentNumChars >= CurrentSize)
				{
				char * pChar;
				CurrentSize += StartingSize;
				pChar		=  new char [CurrentSize + 1];
				memcpy (pChar, pStr, CurrentNumChars);
				delete [] pStr;
				pStr = pChar;
				}
			else;
		}
	pStr [CurrentNumChars] = '\0';
	return pStr;
	}


ReadString.h
1
2
3
4
5
6
#ifndef READ_STRING_H
#define READ_STRING_H

char * ReadString ();

#endif 


ReadFunctions.h
1
2
3
4
5
6
7
8
9
10
#ifndef READ_FUNCTIONS_H
#define READ_FUNCTIONS_H

typedef unsigned int	UINT;

double	ReadDouble	();
UINT	ReadHex		();
int		ReadInteger	();

#endif 


Party.h
1
2
3
4
5
6
7
8
9
10
11
#ifndef PARTY_H
#define PARTY_H

struct Party
	{
	char *	pName;
	long	Size;
	char 	Plane;
	};

#endif 


closed account (2A7X92yv)
main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <iostream>

using namespace std;

#include <stdlib.h>

#include <iostream>

using namespace std;

#include "Party.h"
#include "Plane.h"
#include "ReadFunctions.h"
#include "ReadString.h"

enum CommandList {ALFA, BRAVO, LOUNGE, ARRIVE, FLY, SHUTDOWN, INVALID};

void		Move		(Plane &, Plane &);
CommandList	ReadCommand	();

void main ()
	{
	int		i;
	long	j;
	Plane		Alfa;
	Plane		Bravo;
	Plane		Lounge;
	Party		Parties;

	bool		Done;
	bool		AlfaInitialized;
	bool		BravoInitialized;
	bool		LoungeInitialized;
	CommandList	Command;

	AlfaInitialized		= false;
	BravoInitialized	= false;
	LoungeInitialized	= false;

	do	{
		if (!AlfaInitialized)
							{
							Alfa.PlaneAbbrev	= 'A';
							cout << "Enter number of ALFA seats: ";
							Alfa.NumSeats		= ReadInteger ();
							Alfa.NumEmptySeats	= Alfa.NumSeats;
							Alfa.NumParties		= 0;
							Alfa.pParty			= new Party [Alfa.NumSeats];
							AlfaInitialized		= true;
							cout << "ALFA initialized." << endl;
							}
						else
							cout << "ALFA is already initialized" << endl;
		if (!BravoInitialized)
							{
							Bravo.PlaneAbbrev	= 'B';
							cout << "Enter number of BRAVO seats: ";
							Bravo.NumSeats		= ReadInteger ();
							Bravo.NumEmptySeats	= Bravo.NumSeats;
							Bravo.NumParties		= 0;
							Bravo.pParty			= new Party [Bravo.NumSeats];
							BravoInitialized		= true;
							cout << "BRAVO initialized." << endl;
							}
						else
							cout << "BRAVO is already initialized" << endl;
		
		
		if (!LoungeInitialized)
							{
							Lounge.PlaneAbbrev	= 'L';
							cout << "Enter number of Lounge seats: ";
							Lounge.NumSeats		= ReadInteger ();
							Lounge.NumEmptySeats	= Lounge.NumSeats;
							Lounge.NumParties		= 0;
							Lounge.pParty			= new Party [Lounge.NumSeats];
							LoungeInitialized		= true;
							cout << "Lounge initialized." << endl;
							}
						else
							cout << "Lounge is already initialized" << endl;					
			
		} while (!AlfaInitialized || !BravoInitialized || !LoungeInitialized);
	Done = false;
	do	{
		cout << "Enter a command (ARRIVE, FLY, SHUTDOWN): ";
		Command = ReadCommand ();
		switch (Command)
			{
			case ARRIVE:
					cout << "Enter number of members in party: ";
					Parties.Size = ReadInteger ();	
					cout << "Party size entered is " << Parties.Size << endl;
					cout << "Enter which plane the party will be on: ";
					Parties.Plane = ReadCommand ();
					switch (Parties.Plane)
						{
						case ALFA:
							Parties.pName = new char [Parties.Size];
							Parties.Plane = 'A';
							for (i = 0; i < Parties.Size; i++)
								{
								cout << "Enter name [" << i + 1 << "] or press Enter to continue: ";
								Parties.pName [i] = *ReadString ();
								}
							break;
						case BRAVO:
							Parties.pName = new char [Parties.Size];
							Parties.Plane = 'B';
							for (i = 0; i < Parties.Size; i++)
								{
								cout << "Enter name [" << i + 1 << "] or press Enter to continue: ";
								Parties.pName [i] = *ReadString ();
								}				
							break;
						default:
							cout << "Invalid Command." << endl;
						}
			
			
			case FLY:
				// if plane is Alfa
						// print the names of all parties on the plane
						// take everybody off the plane
						Move (Alfa, Lounge);
					//else	// plane is Bravo
						// print the names of all parties on the plane
						// take everybody off the plane
						Move (Bravo, Lounge);
				break;
			case SHUTDOWN:
				Done = true;
				break;
			default:
				cout << "Invalid Command" << endl;
			}
		} while (!Done);
	}
CommandList ReadCommand ()
	{
	char *		CommandString;
	CommandList	Command;

	CommandString = ReadString ();
	if (_strcmpi (CommandString, "ALFA") == 0)
			Command = ALFA;
		else
			if (_strcmpi (CommandString, "BRAVO") == 0)
					Command = BRAVO;
				else
					if (_strcmpi (CommandString, "LOUNGE") == 0)
							Command = LOUNGE;
						else
							if (_strcmpi (CommandString, "ARRIVE") == 0)
									Command = ARRIVE;
								else
									if (_strcmpi (CommandString, "FLY") == 0)
											Command = FLY;
										else
											if (_strcmpi (CommandString, "SHUTDOWN") == 0)
													Command = SHUTDOWN;
												else
													Command = INVALID;
	delete [] CommandString;
	return Command;
	}

void Move (Plane & To, Plane & From)
	{
	long	i;
	long	j;

	for (i = 0; i < From.NumParties; i++)
		if ((From.pParty [i].Plane == To.PlaneAbbrev) && (From.pParty [i].Size <= To.NumEmptySeats))
				{
				To.pParty [To.NumParties] = From.pParty [i];
				To.NumParties++;
				To.NumEmptySeats			-= From.pParty [i].Size;
				From.NumEmptySeats			+= From.pParty [i].Size;
				for (j = i + 1; j < From.NumParties; j++)
					From.pParty [j - 1] = From.pParty [j];
				From.NumParties--;
			}
	}


So Thats where i am upto.. now.. I need ur serious help...
I dont know where to go from.. here... Please help me guide... I want some one to seriously help me please... I will be very thankful for any of your efforts.. small or big...

THANKS MEAN A LOT
closed account (2A7X92yv)
anyone???
Topic archived. No new replies allowed.