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

Second Commit

parent 23287c61
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 5.0.3, 2022-05-03T11:54:16. -->
<!-- Written by QtCreator 5.0.3, 2022-05-03T20:11:30. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......@@ -242,7 +242,6 @@
<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>
......
#include"Patient.h"
int Patient::storIdNumber = 100000; // <= sttic variable initialisieren
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(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()
{
iD=value(mt);
firstName = "FirstName";
lastName = "lastName";
gender = "X";
birthDay ="DD.MM.JJJJ";
diagnose = simulant;
}
string Patient::FirstName_and_Gender_RandomGen()
{
string randMFirstName;
bool is_male =rand() &1;
if(is_male ==true){
randMFirstName = firstNames_male.at(rand()%50);
gender = "Male";
}
else{
randMFirstName = firstNames_female.at(rand()%50);
gender = "Female";
}
return randMFirstName;
}
void Patient::randomize_dob()
{
int dayOfbirth = rand()%31+1;
string dayOfbirthAsString = to_string(dayOfbirth);
int monthOfbirth = rand()%12+1;
string monthOfBirthAsString = to_string(monthOfbirth);
int yearOfbirth = rand()%(2002 - 1980 +1) + 1980 ;
string yearOfBirthAsString = to_string(yearOfbirth);
birthDay = dayOfbirthAsString + "." +monthOfBirthAsString + "."+ yearOfBirthAsString;
}
void Patient::randomize_data()
{
firstName = FirstName_and_Gender_RandomGen();
lastName = lastNames.at(rand()%50);
randomize_dob();
randomize_dignose();
}
int Patient::getTreatmentDuration(){ //getter for "Treatment Duration"
return treatmentDuration;
}
......@@ -25,8 +79,8 @@ void Patient::setTreatmentDuration(int duration){ //set Treatmen Duration
}
void Patient::setDiagnose(Diagnose d){
diagnose = d;
void Patient::setDiagnose(Diagnose diagnose){
this->diagnose = diagnose;
}
Diagnose Patient::getDiagnose(){
......@@ -52,13 +106,13 @@ void Patient::tDuration(Diagnose d){ //method to set the value of the tr
void Patient::print(){ // Ausgabe der Patientendaten
cout<<"\nInformations about the Patient :\n"<<endl
<<"ID:"<< iD <<endl //
<<"ID:"<< iD <<endl //
<<"First Name : " <<firstName<<endl
<<"Last Nmae: "<<lastName<<endl
<<"Gender: "<<gender<<endl
<<"Birthday: "<<birthDay<<endl
<<"Diagnosis: "<< diagosisAsString.at(diagnose) <<endl //!!!!
<<"Treatment Duration: "<< treatmentDuration <<endl;
<<"Last Nmae: "<<lastName<<endl
<<"Gender: "<<gender<<endl
<<"Birthday: "<<birthDay<<endl
<<"Diagnosis: "<< diagosisAsString.at(diagnose) <<endl //!!!!
<<"Treatment Duration: "<< treatmentDuration <<endl;
}
void Patient::reduceTDuration(int reducedDays){ //eine Möglichkeit zur Reduzierung der Restbehandlungsdauer
......@@ -82,34 +136,58 @@ void Patient::reduceTDuration(int reducedDays){ //eine Möglichkeit zur Reduzi
}
}
void Patient::resettDiagnose(Diagnose d){ //Resett Diagnose <=> Resett treatment duration (method tDuration)
diagnose = d;
tDuration(d);
void Patient::resettDiagnose(Diagnose diagnose){ //Resett Diagnose <=> Resett treatment duration (method tDuration)
this->diagnose = diagnose;
tDuration(diagnose);
}
//um Patient rand mit ein integer zu gen.
void Patient::resettDiagnosisWhitanInt(int i){
if (i == 0){
void Patient::randomize_dignose()
{
int number_of_Diagnosis =4;
int type_of_Diagnose = rand()%number_of_Diagnosis;
if (type_of_Diagnose == 0){
setDiagnose(simulant);
tDuration(simulant);
}
else if(i == 1){
else if(type_of_Diagnose == 1){
setDiagnose(infection);
tDuration(infection);
}
else if(i == 2){
else if(type_of_Diagnose == 2){
setDiagnose(fracture);
tDuration(fracture);
}
else if(i == 3){
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;
}
//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){
......@@ -132,11 +210,16 @@ void Patient::resettDiagnosisWhitanInt(int i){
int Patient::getStaticIDnumber(){ //Getter for the static idNumber variable
return storIdNumber;
}
int Patient::getID(){
return iD;
}
Patient::Patient(const string &firstName, const string &lastName, const string &birthDay) : firstName(firstName),
lastName(lastName),
birthDay(birthDay)
{}
Patient::Patient(const string &firstName, const string &lastName) : firstName(firstName),
lastName(lastName)
{}
......@@ -3,9 +3,12 @@
#include<iostream>
#include<string>
#include<array>
#include<random>
constexpr int MAX_NUMBER_OF_NAMES =50;
using namespace std;
const array<std::string, 50> firstNames_male = {
const array<std::string, MAX_NUMBER_OF_NAMES> firstNames_male = {
"Tanguy",
"Linus",
"Anton",
......@@ -57,7 +60,7 @@ const array<std::string, 50> firstNames_male = {
"Joris",
"Kilian"};
const array<std::string, 50>firstNames_female= {
const array<std::string, MAX_NUMBER_OF_NAMES>firstNames_female= {
"Lima",
"Emilia",
"Ella",
......@@ -109,7 +112,7 @@ const array<std::string, 50>firstNames_female= {
"Lara",
"Elina"};
const array<std::string, 50> lastNames = {
const array<std::string, MAX_NUMBER_OF_NAMES> lastNames = {
"Mueller",
"Schmidt",
"Schneider",
......@@ -176,6 +179,8 @@ const array<string, 4> diagosisAsString = {
"simulant", "infection", "fracture" , "cured"
};
//Patient.h
class Patient{
private:
......@@ -185,20 +190,26 @@ private:
string birthDay ;
Diagnose diagnose ;
int treatmentDuration ;
int iD;
static int storIdNumber; // <=
//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 = "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 d);
void setDiagnose(Diagnose diagnose);
Diagnose getDiagnose();
void tDuration(Diagnose d);
......@@ -207,8 +218,8 @@ public:
void reduceTDuration(int reducedDays); //eine Möglichkeit zur Reduzierung der Restbehandlungsdauer
void resettDiagnose(Diagnose d); //Möglichkeit zur Anpassung der Diagnose
void resettDiagnosisWhitanInt(int i);
void resettDiagnose(Diagnose diagnose); //Möglichkeit zur Anpassung der Diagnose
void randomize_dignose();
//void tDurationToDiagnose(int n); //Another Method to set the diagnosis Type from a given Treatment Duration
static int getStaticIDnumber();
......
#include"hospital.h"
#include"Patient.h"
Hospital::Hospital(int nB){
if(nB >0){ //just to check the given parameter
numberBeds = nB;
Hospital::Hospital(int number_of_Beds){
if(number_of_Beds >0){ //just to check the given parameter
numberBeds = number_of_Beds;
}
else
cout<<"Number of beds must be > 0"<<endl;
......@@ -15,13 +13,14 @@ int Hospital::getNumberBets(){ //getter for NumberBeds
return numberBeds;
}
void Hospital::setNumberBeds(int nB){ //setter for NumberBeds
numberBeds = nB;
void Hospital::setNumberBeds(int newNumberBeds)
{
numberBeds = newNumberBeds;
}
void Hospital::newPatient(Patient p){ //!!!
void Hospital::newPatient(Patient patient){ //!!!
if(numberBeds > 0){
patientsList.push_back(p);
patientsList.push_back(patient);
numberBeds--;
}
/*else{
......@@ -29,22 +28,22 @@ void Hospital::newPatient(Patient p){ //!!!
}*/
}
void Hospital::reduceTraitementDurationH(int nReducedDays){
void Hospital::reduceTraitementDurationH(int number_of_Days_reduced){
for(size_t i = 0; i< patientsList.size(); i++){
patientsList.at(i).reduceTDuration(nReducedDays);
patientsList.at(i).reduceTDuration(number_of_Days_reduced);
}
}
void Hospital::printh(){
void Hospital::print_Patient_list(){
for(Patient i : patientsList){
i.print();
cout<<"-----------------------------------------"<<endl;
}
}
void Hospital::deleteHPatient(int n){ // prüf ob ID in Rang ist
void Hospital::deleteHPatient(int index_of_Patient){ // prüf ob ID in Rang ist
for(size_t i = 0; i < patientsList.size() ; i++){
if(patientsList.at(i).getID() == n ){
if(patientsList.at(i).getID() == index_of_Patient ){
patientsList.erase(patientsList.begin() + i);
break;
}
......
......@@ -9,18 +9,18 @@ private:
vector<Patient> patientsList;
public:
Hospital(int nB);
void newPatient(Patient p); // neue Patienten in die Patientenliste hinzuzufügen, sofern noch Betten verfügbar sind
int getNumberBets(); //Setter for NumberBeds
void setNumberBeds(int nB); //Getter for NumberBeds
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 reduceTraitementDurationH(int number_of_Days_reduced);
void reduceTraitementDurationH(int nReducedDays);
void print_Patient_list();
void printh();
void deleteHPatient(int i);
void deleteHPatient(int index_of_Patient);
void deleteCuredPatients();
};
#endif // HOSPITAL_H
#include <iostream>
#include"Patient.h"
#include"hospital.h"
#include"time.h"
//Patient function => returns a rand Patient
Patient genRandPatient(){
string randMFirstName;
string gender;
int g = rand()%2;
if(g == 0){
randMFirstName = firstNames_male.at(rand()%50);
gender = genderAsString.at(g);
}
else if(g==1) {
randMFirstName = firstNames_female.at(rand()%50);
gender = genderAsString.at(g);
}
string randLastName = lastNames.at(rand()%50);
int dayOfbirth = rand()%31+1;
string dayOfbirthAsString = to_string(dayOfbirth);
int monthOfbirth = rand()%12+1;
string monthOfBirthAsString = to_string(monthOfbirth);
int yearOfbirth = rand()%(2002 - 1980 +1) + 1980 ;
string yearOfBirthAsString = to_string(yearOfbirth);
string birthDay = dayOfbirthAsString + "." +monthOfBirthAsString + "."+ yearOfBirthAsString;
Patient randPatient(randMFirstName, randLastName ,gender, birthDay);
int diagnosis = rand()%4;
randPatient.resettDiagnosisWhitanInt(diagnosis);
return randPatient; // Add Patient
Patient randomPatient = Patient();
randomPatient.randomize_data();
return randomPatient; // Add Patient
}
int main()
......@@ -42,16 +15,13 @@ int main()
srand(time(NULL));
Hospital HospitalDA(60); // number of beds as const!! New hospital
for(int nb = 0; nb < 61; nb++){
for(int number_of_beds = 0; number_of_beds < 61; number_of_beds++){
HospitalDA.newPatient(genRandPatient());
}
HospitalDA.printh();
HospitalDA.print_Patient_list();
//HospitalDA.reduceTraitementDurationH(2);
HospitalDA.deleteCuredPatients();
HospitalDA.printh();
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