Data Structure Proposal
Data Structure Proposal
#include<conio.h>
#include<string>
// define maximum number of patients in a queue
#define MAXPATIENTS 100
using namespace std;
// define structure for patient data
struct patient
{
char FirstName[50];
char LastName[50];
char ID[20];
};
// define class for queue
class queue
{
public:
queue(void);
int AddPatientAtEnd(patient p);
int AddPatientAtBeginning(patient p);
patient GetNextPatient(void);
int RemoveDeadPatient(patient * p);
void OutputList(void);
char DepartmentName[50];
private:
int NumberOfPatients;
patient List[MAXPATIENTS];
};
// declare member functions for queue
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 queue::AddPatientAtBeginning(patient p)
{
// adds a critically ill patient to the beginning of the queue.
// returns 1 if successful, 0 if queue is full.