Commit 2a9000d9 authored by Dang Quang Tran's avatar Dang Quang Tran
Browse files

Third Commit

parent 2e96a3dd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 5.0.3, 2022-05-03T20:11:30. -->
<!-- Written by QtCreator 5.0.3, 2022-05-04T02:45:19. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......@@ -83,6 +83,9 @@
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
<value type="bool" key="UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
......@@ -235,13 +238,15 @@
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/stud/Desktop/Hospital/ooad-prak01/HospitalP4.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/stud/Desktop/Hospital/ooad-prak01/HospitalP4.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">HospitalP42</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/stud/OOAD22/ooad_praktikum01/HospitalP4.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/stud/OOAD22/ooad_praktikum01/HospitalP4.pro</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/stud/Desktop/build-HospitalP4-Desktop-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
......
......@@ -3,20 +3,7 @@
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> value(1000,9999);
//int Patient::storIdNumber = 100000; // <= sttic variable initialisieren
//p.cpp
//Patient::Patient(string fName , string lName , string g , string bDay ,Diagnose d){
// firstName = fName;
// lastName = lName;
// gender = g;
// birthDay = bDay;
// diagnose = d;
// tDuration(d);
// iD = storIdNumber; //iD initialized
// // stors iD and adds 1 to it
// storIdNumber++;
//}
Patient::Patient()
{
......@@ -70,11 +57,11 @@ void Patient::randomize_data()
int Patient::getTreatmentDuration(){ //getter for "Treatment Duration"
int Patient::getTreatmentDuration(){
return treatmentDuration;
}
void Patient::setTreatmentDuration(int duration){ //set Treatmen Duration
void Patient::setTreatmentDuration(int duration){
treatmentDuration = duration;
}
......@@ -88,7 +75,7 @@ Diagnose Patient::getDiagnose(){
}
void Patient::tDuration(Diagnose d){ //method to set the value of the treatmentDuration //according to the diagnose statut
void Patient::tDuration(Diagnose d){ //according to the diagnose statut
if(d == simulant){
setTreatmentDuration(2);
}
......@@ -104,20 +91,20 @@ void Patient::tDuration(Diagnose d){ //method to set the value of the tr
}
void Patient::print(){ // Ausgabe der Patientendaten
void Patient::print(){
cout<<"\nInformations about the Patient :\n"<<endl
<<"ID:"<< iD <<endl //
<<"First Name : " <<firstName<<endl
<<"Last Nmae: "<<lastName<<endl
<<"Gender: "<<gender<<endl
<<"Birthday: "<<birthDay<<endl
<<"Diagnosis: "<< diagosisAsString.at(diagnose) <<endl //!!!!
<<"Diagnosis: "<< diagosisAsString.at(diagnose) <<endl
<<"Treatment Duration: "<< treatmentDuration <<endl;
}
void Patient::reduceTDuration(int reducedDays){ //eine Möglichkeit zur Reduzierung der Restbehandlungsdauer
void Patient::reduceTDuration(int reducedDays){
int remainedTDays ;
if(reducedDays > 0){ //if the given parameter is positive
if(reducedDays > 0){
remainedTDays = getTreatmentDuration() - reducedDays;
if(remainedTDays <= 0){
setDiagnose(cured);
......@@ -126,7 +113,7 @@ void Patient::reduceTDuration(int reducedDays){ //eine Möglichkeit zur Reduzi
setTreatmentDuration(remainedTDays);
}
else{
reducedDays *= -1; //if the given parameter is negative..take the enverse of it
reducedDays *= -1;
remainedTDays = getTreatmentDuration() - reducedDays;
if(remainedTDays <= 0){
setDiagnose(cured);
......@@ -136,7 +123,7 @@ void Patient::reduceTDuration(int reducedDays){ //eine Möglichkeit zur Reduzi
}
}
void Patient::resettDiagnose(Diagnose diagnose){ //Resett Diagnose <=> Resett treatment duration (method tDuration)
void Patient::resettDiagnose(Diagnose diagnose){
this->diagnose = diagnose;
tDuration(diagnose);
}
......@@ -165,49 +152,6 @@ void Patient::randomize_dignose()
cout<<"Error out of range (Enum has only 4 elements (0, 1 , 2, 3) "<<endl;
}
//um Patient rand mit ein integer zu gen.
//void Patient::resettDiagnosisWhitanInt(int type_of_Diagnose){
// if (type_of_Diagnose == 0){
// setDiagnose(simulant);
// tDuration(simulant);
// }
// else if(type_of_Diagnose == 1){
// setDiagnose(infection);
// tDuration(infection);
// }
// else if(type_of_Diagnose == 2){
// setDiagnose(fracture);
// tDuration(fracture);
// }
// else if(type_of_Diagnose == 3){
// setDiagnose(cured);
// tDuration(cured);
// }
// else
// cout<<"Error out of range (Enum has only 4 elements (0, 1 , 2, 3) "<<endl;
//}
//method to set the Type of diagnosis From a given parameter number
//void Patient::tDurationToDiagnose(int n){
// if(n >=2 && n < 14){
// resettDiagnose(simulant);
// }
// else if(n >= 14 && n <42){
// resettDiagnose(infection);
// }
// else if(n >=42){
// resettDiagnose(fracture);
// }
// if(n == 0){
// resettDiagnose(cured);
// }
// // just to check the given Parameter
//// else
//// treatmentDuration = n;
//}
......
......@@ -164,10 +164,7 @@ const array<std::string, MAX_NUMBER_OF_NAMES> lastNames = {
"Hahn",
"Keller"};
//Gender for rand Patient in main
enum gender{
Male, Female
};
const array<string, 2> genderAsString{
"Male", "Female"
};
......@@ -180,8 +177,6 @@ const array<string, 4> diagosisAsString = {
};
//Patient.h
class Patient{
private:
string firstName ;
......@@ -191,37 +186,34 @@ private:
Diagnose diagnose ;
int treatmentDuration ;
int iD;
//static int storIdNumber; // <=
public:
Patient(const string &firstName, const string &lastName);
Patient(const string &firstName, const string &lastName, const string &birthDay);
//Patient( string firstName = "FirstName" , string lastName = "lastName", string gender = "X" , string birthDay ="DD.MM.JJJJ" , Diagnose diagnose = simulant);
Patient();
string FirstName_and_Gender_RandomGen();
void randomize_dob();
void randomize_data();
//Getter and Setter for the treatment Duration
int getTreatmentDuration();
void setTreatmentDuration(int duration);
//Setter for the diagnosis
void setDiagnose(Diagnose diagnose);
Diagnose getDiagnose();
void tDuration(Diagnose d);
void print(); // Ausgabe der Patientendaten
void print();
void reduceTDuration(int reducedDays); //eine Möglichkeit zur Reduzierung der Restbehandlungsdauer
void reduceTDuration(int reducedDays);
void resettDiagnose(Diagnose diagnose); //Möglichkeit zur Anpassung der Diagnose
void resettDiagnose(Diagnose diagnose);
void randomize_dignose();
//void tDurationToDiagnose(int n); //Another Method to set the diagnosis Type from a given Treatment Duration
static int getStaticIDnumber();
int getID();
......
......@@ -2,14 +2,14 @@
Hospital::Hospital(int number_of_Beds){
if(number_of_Beds >0){ //just to check the given parameter
if(number_of_Beds >0){
numberBeds = number_of_Beds;
}
else
cout<<"Number of beds must be > 0"<<endl;
}
int Hospital::getNumberBets(){ //getter for NumberBeds
int Hospital::getNumberBets(){
return numberBeds;
}
......@@ -18,14 +18,14 @@ void Hospital::setNumberBeds(int newNumberBeds)
numberBeds = newNumberBeds;
}
void Hospital::newPatient(Patient patient){ //!!!
void Hospital::newPatient(Patient patient){
if(numberBeds > 0){
patientsList.push_back(patient);
numberBeds--;
}
/*else{
else{
cout<<"Sorry no beds left for a new Patient. "<<endl;
}*/
}
}
void Hospital::reduceTraitementDurationH(int number_of_Days_reduced){
......@@ -41,7 +41,7 @@ void Hospital::print_Patient_list(){
}
}
void Hospital::deleteHPatient(int index_of_Patient){ // prüf ob ID in Rang ist
void Hospital::deleteHPatient(int index_of_Patient){
for(size_t i = 0; i < patientsList.size() ; i++){
if(patientsList.at(i).getID() == index_of_Patient ){
patientsList.erase(patientsList.begin() + i);
......
......@@ -10,9 +10,9 @@ private:
public:
Hospital(int number_of_Beds);
void newPatient(Patient patient); // neue Patienten in die Patientenliste hinzuzufügen, sofern noch Betten verfügbar sind
int getNumberBets(); //Setter for NumberBeds
void setNumberBeds(int newNumberBeds); //Getter for NumberBeds
void newPatient(Patient patient);
int getNumberBets();
void setNumberBeds(int newNumberBeds);
void reduceTraitementDurationH(int number_of_Days_reduced);
void print_Patient_list();
......
......@@ -2,11 +2,10 @@
#include"hospital.h"
#include"time.h"
//Patient function => returns a rand Patient
Patient genRandPatient(){
Patient randomPatient = Patient();
randomPatient.randomize_data();
return randomPatient; // Add Patient
return randomPatient;
}
int main()
......@@ -14,13 +13,12 @@ int main()
cout<<"Hello";
srand(time(NULL));
Hospital HospitalDA(60); // number of beds as const!! New hospital
Hospital HospitalDA(60);
for(int number_of_beds = 0; number_of_beds < 61; number_of_beds++){
HospitalDA.newPatient(genRandPatient());
}
HospitalDA.print_Patient_list();
//HospitalDA.reduceTraitementDurationH(2);
HospitalDA.deleteCuredPatients();
HospitalDA.print_Patient_list();
return 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment