Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Dang Quang Tran
OOAD_Praktikum01
Commits
2e96a3dd
Commit
2e96a3dd
authored
May 03, 2022
by
Dang Quang Tran
Browse files
Second Commit
parent
23287c61
Changes
6
Hide whitespace changes
Inline
Side-by-side
HospitalP4.pro.user
View file @
2e96a3dd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 5.0.3, 2022-05-03T
11:54:16
. -->
<!-- Written by QtCreator 5.0.3, 2022-05-03T
20: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>
...
...
Patient.cpp
View file @
2e96a3dd
#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
d
iagnose
){
this
->
diagnose
=
d
iagnose
;
}
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
<<
"
\n
Informations 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
d
iagnose
){
//Resett Diagnose <=> Resett treatment duration (method tDuration)
this
->
diagnose
=
d
iagnose
;
tDuration
(
d
iagnose
);
}
//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
)
{}
Patient.h
View file @
2e96a3dd
...
...
@@ -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
d
iagnose
);
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
r
esettDiagnosisWhitanInt
(
int
i
);
void
resettDiagnose
(
Diagnose
d
iagnose
);
//Möglichkeit zur Anpassung der Diagnose
void
r
andomize_dignose
(
);
//void tDurationToDiagnose(int n); //Another Method to set the diagnosis Type from a given Treatment Duration
static
int
getStaticIDnumber
();
...
...
hospital.cpp
View file @
2e96a3dd
#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
p
atient
){
//!!!
if
(
numberBeds
>
0
){
patientsList
.
push_back
(
p
);
patientsList
.
push_back
(
p
atient
);
numberBeds
--
;
}
/*else{
...
...
@@ -29,22 +28,22 @@ void Hospital::newPatient(Patient p){ //!!!
}*/
}
void
Hospital
::
reduceTraitementDurationH
(
int
n
ReducedDays
){
void
Hospital
::
reduceTraitementDurationH
(
int
n
umber_of_Days_reduced
){
for
(
size_t
i
=
0
;
i
<
patientsList
.
size
();
i
++
){
patientsList
.
at
(
i
).
reduceTDuration
(
n
ReducedDays
);
patientsList
.
at
(
i
).
reduceTDuration
(
n
umber_of_Days_reduced
);
}
}
void
Hospital
::
print
h
(){
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
;
}
...
...
hospital.h
View file @
2e96a3dd
...
...
@@ -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
main.cpp
View file @
2e96a3dd
#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
n
b
=
0
;
nb
<
61
;
nb
++
){
for
(
int
n
umber_of_beds
=
0
;
number_of_beds
<
61
;
number_of_beds
++
){
HospitalDA
.
newPatient
(
genRandPatient
());
}
HospitalDA
.
print
h
();
HospitalDA
.
print
_Patient_list
();
//HospitalDA.reduceTraitementDurationH(2);
HospitalDA
.
deleteCuredPatients
();
HospitalDA
.
printh
();
HospitalDA
.
print_Patient_list
();
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment