Skip to content

Instantly share code, notes, and snippets.

@bilinin
Created February 28, 2017 16:57
Show Gist options
  • Save bilinin/f5ae6c44012d8427f9cb7a13052eed72 to your computer and use it in GitHub Desktop.
Save bilinin/f5ae6c44012d8427f9cb7a13052eed72 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
class Patient{
public:
// Конструктор
Patient(string FirstName, string LastName, string MiddleName, string Adress, string Diagnosis,int CardNumber){
set_first_name(FirstName);
set_last_name(LastName);
set_middle_name(MiddleName);
set_adress(Adress);
set_disgnosis(Diagnosis);
set_card_number(CardNumber);
}
// Сеттеры
void set_first_name(string first_name){
FirstName = first_name;
}
void set_last_name(string last_name){
LastName = last_name;
}
void set_middle_name(string middle_name){
MiddleName = middle_name;
}
void set_card_number(int card_number){
CardNumber = card_number;
}
void set_adress(string adress){
Adress = adress ;
}
void set_disgnosis(string diagnosis){
Diagnosis = diagnosis ;
}
// Геттеры
string get_first_name(){
return FirstName;
}
string get_last_name(){
return LastName;
}
string get_middle_name(){
return MiddleName;
}
string get_adress(){
return Adress;
}
int get_card_number(){
return CardNumber;
}
string get_diagnosis(){
return Diagnosis;
}
// other
void print_all_data(){
cout << FirstName << " " << LastName << " " << MiddleName << " "
<< Adress << " " << Diagnosis << " " << CardNumber << endl;
}
private:
string FirstName,
LastName,
MiddleName,
Adress,
Diagnosis;
int CardNumber;
};
void search_diagnosis(vector <Patient> Patients, string diagnosis ){
cout << "\n\nDiagnosis "<< diagnosis <<": \n";
int size = Patients.size();
for(int i=0;i<size;i++){
if (Patients[i].get_diagnosis() == diagnosis){
Patients[i].print_all_data();
}
}
}
void search_card_interval(vector <Patient> Patients, int begin, int end ){
cout << "\n\nCard numder in interval from "<< begin << " to " << end << endl;
int size = Patients.size();
for(int i=0;i<size;i++){
if ((Patients[i].get_card_number() > begin)&&(Patients[i].get_card_number() < end)){
Patients[i].print_all_data();
}
}
}
int main() {
vector <Patient> Patients;
Patients.push_back(Patient("Ivan","Ivanov","Ivanovich","Kropotkina 10","migraine",100)); // мигрень
Patients.push_back(Patient("Petr","Petrov","Petrovich","Kropotkina 20","migraine",101));
Patients.push_back(Patient("Andrey","Pushkin","Ivanovich","Kropotkina 21","migraine",102));
Patients.push_back(Patient("Oleg","Kalinin","Vladimirovich","Titova 23","cough",103)); // кашель
Patients.push_back(Patient("Regina","Makarova","Daniilovna","Titova 23","cough",104));
Patients.push_back(Patient("Evgeny","Abramov","Pavlovich","Dekabristov 7","migraine",105));
Patients.push_back(Patient("Vladimir","Maksimov","Andreevich","Lenina 5","cough",106));
Patients.push_back(Patient("Oksna","Muhina","Artemovna","Bogatkova 63","migraine",107));
search_diagnosis(Patients, "migraine");
search_card_interval(Patients, 102, 106);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment