Professional Documents
Culture Documents
Hotel Management
Hotel Management
Hotel Management
h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
struct patient
char FirstName[50];
char LastName[50];
char ID[20];
};
class queue
public:
queue (void);
char DepartmentName[50];
private:
int NumberOfPatients;
patient List[MAXPATIENTS];
};
// declare member functions for queue
queue::queue ()
// constructor
NumberOfPatients = 0;
// queue is full
return 0;
else
List[NumberOfPatients] = p; NumberOfPatients++;
return 1;
int i;
// queue is full
return 0;
}
List[i+1] = List[i];
List[0] = p; NumberOfPatients++;
return 1;
int i; patient p;
if (NumberOfPatients == 0) {
// queue is empty
strcpy(p.ID,"");
return p;}
p = List[0];
NumberOfPatients--;
List[i] = List[i+1];
// return patient
return p;
}
int queue::RemoveDeadPatient (patient * p)
int i, j, found = 0;
if (stricmp(List[i].ID, p->ID) == 0)
*p = List[i]; found = 1;
NumberOfPatients--;
List[j] = List[j+1];
return found;
int i;
if (NumberOfPatients == 0)
Queue is empty";
}
else
patient p;
cin.getline(p.FirstName, sizeof(p.FirstName));
cin.getline(p.LastName, sizeof(p.LastName));
cin.getline(p.ID, sizeof(p.ID));
// rejected
strcpy(p.ID,"");
getch();
return p;
if (p == NULL || p->ID[0]==0)
No patient";
return;
else
Patient data:";
int ReadNumber()
char buffer[20];
cin.getline(buffer, sizeof(buffer));
return atoi(buffer);
// this function defines the user interface with menu for one
department
while (choice != 6)
// clear screen
clrscr();
// print menu
5: List queue";
";
choice = ReadNumber();
// do indicated action
switch (choice)
p = InputPatient();
if (p.ID[0])
success = q->AddPatientAtEnd(p);
clrscr();
if (success)
Patient added:
";
else
// error
OutputPatient(&p);
getch();
break;
p = InputPatient();
if (p.ID[0])
success = q->AddPatientAtBeginning(p);
clrscr();
if (success)
Patient added:
";
else
// error
patient:";
OutputPatient(&p);
getch();
break;
p = q->GetNextPatient();
clrscr();
if (p.ID[0])
Patient to operate:
";
OutputPatient(&p);}
else
getch();
break;
p = InputPatient();
if (p.ID[0])
success = q->RemoveDeadPatient(&p);
clrscr();
if (success)
{
Patient removed:
";
else
// error
";
OutputPatient(&p);
getch();
break;
clrscr();
q->OutputList();
getch(); break;
}
// main function defining queues and main menu
void main ()
int i, MenuChoice = 0;
queue departments[3];
while (MenuChoice != 4)
// clear screen
clrscr();
// print menu
";
4: Exit
";
// get user choice
MenuChoice = ReadNumber();
// is it a department name?