SE Assignment 3
Source Code for UML to C++ Code Conversion
Source Code written by Corey Chong Sheng Jiat on March 26,2003. Tutorial group S8
Process to transfer from Visual C++ to html code is difficult and resulted in colourless syntax and poor spacing. 
Note to tutor:
For easy assessment, you may obtain the .c file C++format code from me, email me at
[email protected]
Some points on the code below: menu for choosing the various functions is primitive and not clearly defined since the requirement is just to show that inheritance is supported and the sequence diagram is strictly adhered to.  Also, for the list of treatments, since it is infinity defined in requirement, I've defined it in array form of 100 entires. 
#include <iostream>
#include <cstring>
using std::cout;
using std::endl;
class Person{
public:
����������� Person(string, int);
����������� void setName(string);
����������� void setDOB(int);
����������� int getDOB(){return DOB;}
����������� string getName(){return Name;}
protected:
����������� int DOB;
����������� string Name;
};
class DoctorPerson : public Person{ //DoctorPerson inherits from Person class
public:
����������� DoctorPerson(string,int);
����������� void setDateEmployed(int);
����������� void setSpeciality(string);
����������� int getDateEmployed(){return date;}
����������� string getSpeciality(){return special;}
protected:
����������� int date;
����������� string special;
};
class Treatment{
public:
����������� Treatment(int,int,int);
����������� void setDate(int);
����������� void setstartTime(int);
����������� void setendTime(int);
����������� int getTreatmentDate(){return TreatmentDate;}
����������� int getstart(){return startTime;}
����������� int getend(){return endTime;}
protected:
����������� int TreatmentDate;
int startTime;
����������� int endTime;
};
class PatientPerson: public Person{ //PatientPerson inherits from Person class
public:
����������� PatientPerson(string,int);
����������� void setInsurance(string);
����������� void setEmployer(string);
����������� void setCount(int);
����������� void getAllTreatment();
����������� string getEmployer(){return employer;}
����������� string getInsurance(){return insurCoy;}
����������� Treatment list[100]; // since multiplicity is infinity, i set it to 100 records
protected:
����������� string employer;
����������� string insurCoy;
����������� int count;  //for count of no of treatments
};
voidPerson::setName(string x){name =x;}
voidPerson::setDOB(int date){DOB = date;}
voidPatientPerson::setCount(int x){ count = x;}
voidPatientPerson::setEmployer(string name){employer = name;}
voidPatientPerson::setInsurance(string name){insurCoy = name;}
voidPatientPerson::getAllTreatment(){
����������� //i left out all the statements displayed etc to compress this code
����������� //comprises of geting the functions as required.
����������� int c = count;
����������� while(c!=0){�����
����������� cout<< list[c].getTreatmentDate();
����������� cout << list[c].getstart();
����������� cout << list[c].getend();
����������� c--;
����������� }
}
voidDoctorPerson::setSpeciality(string special){special = special;}
voidDoctorPerson::setDateEmployed(string tempdate){date = tempdate;}
int void main()
{
����������� int time;
����������� string name;
����������� int tempdate;
����������� int count =0;
����������� while(choice!='x')
����������� {
����������������������� cout << "Select:" << endl;
�����������������������������������<< "1)Doctor Menu" <<  endl;
�����������������������������������<< "2)Enter Patient Records" << endl;
��������������������������������  << "3)Enter treatment for current patient" <<  endl;���������������������������������
����������������������������������� << "4)Get Records" << endl;
������������������������������  << "5)Get All Treatments" << endl;
����������������������������������� << "x)Exit " <<  endl;
����������������������� ��� << "Enter your choice:" << endl;
����������������������� cin >> choice;
����������������������� switch(choice){
����������������������� case 1:
����������������������������������� //undefined for doctor menu... not required.
����������������������������������� break;
����������������������� case 2:
����������������������������������� {
����������������������������������������������� PatientPerson p;
�����������������������������������������������
����������������������������������������������� cout << "Enter Patient's Name:" <<endl;
����������������������������������������������� cin >> name;
����������������������������������������������� p.setName(name);
����������������������������������������������� cout << "Enter Date of Birth:">>endl;
����������������������������������������������� cin>>tempdate;
����������������������������������������������� p.setDOB(tempdate);
����������������������������������������������� cout << "Enter employer's name:">> endl;
����������������������������������������������� cin >> name;
����������������������������������������������� p.setEmployer(name);
����������������������������������������������� cout << "Enter Insurance Company:">> endl;
����������������������������������������������� cin >> name;
����������������������������������������������� p.setInsurance(name);
����������������������������������� }break;
����������������������� case 3:
����������������������������������� {
����������������������������������������������� cout << "Enter treatment date:">> endl;
����������������������������������������������� cin >> tempdate;
����������������������������������������������� p.list[count].Treatmentdate = tempdate;
����������������������������������������������� cout << "Enter treatment start time:">>endl;
����������������������������������������������� cin >> time;
����������������������������������������������� p.list[count].startTime = time;
����������������������������������������������� cout << "Enter treatment end time:">>endl;
����������������������������������������������� cin >> time;
����������������������������������������������� p.list[count].endTime = time;
����������������������������������������������� count += 1; //treatment increase by 1 for patient
����������� ����������������������������������� p.setCount(count);
����������������������������������� }break;
����������������������� case 4:
����������������������������������� // not required
����������������������������������� break;
����������������������� case 5:�
����������������������������������� p.getAllTreatment();
����������������������������������� break;
����������������������� default:
����������������������� case 'x':
����������������������������������� break;
����������������������� }
����������� }
}
HOME
Hosted by www.Geocities.ws

1