Professional Documents
Culture Documents
Code
Code
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
queue::queue ()
{
// constructor
NumberOfPatients = 0;
}
int queue::AddPatientAtEnd (patient p)
{
// adds a normal patient to the end of the queue.
// returns 1 if successful, 0 if queue is full.
if (NumberOfPatients >= MAXPATIENTS)
{
// queue is full
return 0;
}
// put in new patient
else
List[NumberOfPatients] = p; NumberOfPatients++;
return 1;
}
int i; patient p;
if (NumberOfPatients == 0) {
// queue is empty
strcpy(p.ID,"");
return p;}
// get first patient
p = List[0];
// move all remaining patients one position forward in queue
NumberOfPatients--;
for (i=0; i<NumberOfPatients; i++)
{
List[i] = List[i+1];
}
// return patient
return p;
}
Patient data:";
cout << "
int ReadNumber()
{
// this function reads an integer number from the keyboard.
// it is used because input with cin >> doesn't work properly!
char buffer[20];
cin.getline(buffer, sizeof(buffer));
return atoi(buffer);
}
";
}
else
{
// error
cout << "
";
}
else
{
// error
cout << "
OutputPatient(&p);
cout << "
";
}
else
{
// error
cout << "
";
}
OutputPatient(&p);
cout << "
while (MenuChoice != 4)
{
// clear screen
clrscr();
// print menu
cout << "