Advertisement
desislava_topuzakova

PATIENT

Apr 16th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. // ExamPreparationUni.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include<iostream>
  5. #include<iomanip>
  6. #include<math.h>
  7. #include<string>
  8. using namespace std;
  9.  
  10.  
  11. class Patient
  12. {
  13. private:
  14.     string ID;
  15.     string name;
  16.     double values[3];
  17. public:
  18.     Patient();
  19.     Patient(string aID, string name1, double values1[]);
  20.     Patient(string aID, string name1, double v0, double v1, double v2);
  21.     Patient(const Patient &P);
  22.  
  23.     string get_ID();
  24.     string get_name();
  25.     double get_values(int index);
  26.     void set_ID(string aID);
  27.     void set_name(string name1);
  28.     void set_values(double values1[]);
  29.     void set_Patient(string aID, string name1, double v0, double v1, double v2);
  30.     void input();
  31.     void output();
  32.     Patient& operator =(Patient &P);
  33.  
  34. };
  35. Patient::Patient()
  36. {
  37.    
  38.     ID = "";
  39.     name = "";
  40.     for (int i = 0; i<3; i++) {
  41.         values[i] = 0;
  42.     }
  43.  
  44. }
  45. Patient::Patient(string aID, string name1, double values1[3])
  46. {
  47.     ID = aID;
  48.     name = name1;
  49.     for (int i = 0; i<3; i++)
  50.     {
  51.         values[i] = values1[i];
  52.     }
  53. }
  54. Patient::Patient(string aID, string name1, double v0, double v1, double v2)
  55. {
  56.     ID = aID;
  57.     name = name1;
  58.     values[0] = v0;
  59.     values[1] = v1;
  60.     values[2] = v2;
  61. }
  62. Patient::Patient(const Patient &Original)
  63. {
  64.  
  65.     name = Original.name;
  66.     ID = Original.ID;
  67.     for (int i = 0; i<3; i++)
  68.     {
  69.         values[i] = Original.values[i];
  70.     }
  71. }
  72. string Patient::get_ID()
  73. {
  74.     return ID;
  75. }
  76. string  Patient::get_name()
  77. {
  78.     return name;
  79. }
  80. double Patient::get_values(int index)
  81. {
  82.     return values[index];
  83. }
  84. void Patient::set_ID(string aID)
  85. {
  86.     ID = aID;
  87. }
  88. void Patient::set_name(string name1)
  89. {
  90.     name = name1;
  91. }
  92. void Patient::set_values(double values1[])
  93. {
  94.     for (int i = 0; i<3; i++)
  95.     {
  96.         values[i] = values1[i];
  97.     }
  98. }
  99. void Patient::set_Patient(string aID, string name1, double v0, double v1, double v2)
  100. {
  101.     ID = aID;
  102.     name = name1;
  103.     values[0] = v0;
  104.     values[1] = v1;
  105.     values[2] = v2;
  106. }
  107. void Patient::input()
  108. {
  109.     cout << "ID: "; getline(cin, ID);
  110.     cout << "\nName: "; getline(cin, name);
  111.     cout << "\nValues: ";
  112.     for (int i = 0; i<3; i++)
  113.     {
  114.         cin >> values[i];
  115.     }
  116. }
  117. void Patient::output()
  118. {
  119.     cout << endl;
  120.     cout << "ID: " << ID << "\nName: " << name << endl;
  121.     cout << "Values: ";
  122.     for (int i = 0; i<3; i++)
  123.     {
  124.         cout << values[i] << " ";
  125.     }
  126.     cout << endl;
  127. }
  128.  
  129. Patient& Patient::operator= (Patient &P)
  130. {
  131.     this->name = P.name;
  132.     ID = P.ID;
  133.     for (int i = 0; i<3; i++)
  134.     {
  135.         values[i] = P.values [i];
  136.     }
  137.     return *this;
  138. }
  139.  
  140. int main()
  141. {
  142.     Patient P;
  143.     P.set_Patient("1234", "Ivan Ivanov Ivanov", 2.23, 5.50, 4.34);
  144.     P.output();
  145.     system("pause");
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement