Advertisement
Guest User

clinic.cpp

a guest
Mar 19th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.80 KB | None | 0 0
  1. // Clinic.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <iomanip>
  7.  
  8. using namespace std;
  9.  
  10. class Consult
  11. {
  12. private:
  13.     char name[30];
  14. protected:
  15.     int cause;
  16. public:
  17.     int age;
  18.     int num_sec;
  19.     float weight;
  20.     float height;
  21.     char sex;
  22.  
  23. public:
  24.     Consult();
  25.     void Input();
  26.     void Show();
  27. };
  28.  
  29. Consult::Consult()
  30. {
  31.  
  32. }
  33.  
  34. void Consult::Input()
  35. {
  36.     int flag;
  37.     int option;
  38.     int count_patients = 0;
  39.     int count_f = 0;
  40.     int count_f = 0;
  41.     int count_sprain = 0;
  42.     int count_infection = 0;
  43.     int count_alergies = 0;
  44.     int count_burns = 0;
  45.     int count_broken = 0;
  46.     int count_bites = 0;
  47.     int count_cough = 0;
  48.  
  49.     fflush(stdin);
  50.     cout << "Patient data: " << endl;
  51.     cout << "Name: ";
  52.     cin >> name;
  53.     cout << "Age: ";
  54.     cin >> age;
  55.     cout << "Sex (f/m): ";
  56.     cin.get(sex);
  57.     cout << "Security number: ";
  58.     cin >> num_sec;
  59.     cout << "Weight(kg): ";
  60.     cin >> weight;
  61.     cout << "Height(cm): ";
  62.     cin >> height;
  63.  
  64.     cout << "Select cause: " << endl;
  65.     cout << "1. Sprain" << endl;
  66.     cout << "2. Infection" << endl;
  67.     cout << "3. Alergies" << endl;
  68.     cout << "4. Burns" << endl;
  69.     cout << "5. Broken bones" << endl;
  70.     cout << "6. Bites" << endl;
  71.     cout << "7. Cough" << endl;
  72.  
  73.     if (sex == 'f')
  74.         count_f++;
  75.     else if (sex == 'm')
  76.         count_m++;
  77.     else if (cause == 1)
  78.         count_sprain++;
  79.     else if (cause == 2)
  80.         count_infection++;
  81.     else if (cause == 3)
  82.         count_alergies++;
  83.     else if (cause == 4)
  84.         count_burns++;
  85.     else if (cause == 5)
  86.         count_broken++;
  87.     else if (cause == 6)
  88.         count_bites++;
  89.     else if (cause == 7)
  90.         count_cough++;
  91.     else
  92.     {
  93.         flag--;
  94.         count_patients++;
  95.     }
  96.  
  97.     flag++;
  98.     count_patients--;
  99.    
  100.     cout << "\n";
  101. }
  102.  
  103. void Consult::Show()
  104. {
  105.     cout << "\n\n";
  106.     cout << name;
  107.     cout << endl;
  108.     cout << age;
  109.     cout << endl;
  110.     cout << sex;
  111.     cout << endl;
  112.     cout << num_sec;
  113.     cout << endl;
  114.     cout << weight;
  115.     cout << endl;
  116.     cout << height;
  117.     cout << "\n\n";
  118. }
  119.  
  120. int main()
  121. {
  122.     int num_est = 0;
  123.     int num_obj = 0;
  124.     int opt;
  125.     int opt2;
  126.     int i = 0;
  127.     int n = 0;
  128.     int dim;
  129.     Consult *p;
  130.  
  131.     cout << "How many patients were during the day?";
  132.     cin >> dim;
  133.     cout << "\n";
  134.  
  135.     p = new Consult[dim];
  136.  
  137.     if (p == 0)
  138.     {
  139.         cout << "Error, not enough space.";
  140.         return 0;
  141.     };
  142.  
  143.     do
  144.     {
  145.         cout << "   Menu" << endl;
  146.         cout << "1. Register a new patient." << endl;
  147.         cout << "2. See specific patients." << endl;
  148.         cout << "3. Exit." << endl;
  149.         cout << "-----------------------------------------------------------" << endl;
  150.         fflush(stdin);
  151.         cout << "\n Choose an option from the menu(1-3):";
  152.         cin >> opt;
  153.  
  154.         switch (opt)
  155.         {
  156.         case 1:
  157.             (p + num_obj)->Input();
  158.             num_obj++;
  159.             system("cls");
  160.             break;
  161.  
  162.         case 2:
  163.             cout << "Select cause: " << endl;
  164.             cout << "1. Sprain" << endl;
  165.             cout << "2. Infection" << endl;
  166.             cout << "3. Alergies" << endl;
  167.             cout << "4. Burns" << endl;
  168.             cout << "5. Broken bones" << endl;
  169.             cout << "6. Bites" << endl;
  170.             cout << "7. Cough" << endl;
  171.             cin >> opt2;
  172.  
  173.             /*switch (opt2)
  174.             {
  175.             case 1:
  176.                
  177.                 break;
  178.             case 2:
  179.                
  180.                 break;
  181.             case 3:
  182.                
  183.                 break;
  184.             case 4:
  185.                
  186.                 break;
  187.             case 5:
  188.                
  189.                 break;
  190.             case 6:
  191.                
  192.                 break;
  193.             case 7:
  194.                
  195.                 break;
  196.             default:
  197.                 cout << "Not specific cause." << endl;
  198.                 break;
  199.             }
  200.             cout << "\n";
  201.             cout << "---------------" << endl;
  202.             cout << "PATIENTS" << endl;
  203.             cout << "---------------" << endl;
  204.  
  205.             for (i = 0; i<num_obj; i++)
  206.             {
  207.                 cout << "Patient number " << i + 1;
  208.                 cout << ":";
  209.                 (p)->Show();
  210.                 cout << "\n";
  211.             }*/
  212.  
  213.             cout << endl;
  214.             system("pause");
  215.             system("cls");
  216.             break;
  217.  
  218.         case 3:
  219.             break;
  220.  
  221.         default:
  222.             cout << "\n\n Choose a valid option from the menu.\n";
  223.             system("pause");
  224.             system("cls");
  225.  
  226.         }
  227.  
  228.     }
  229.  
  230.     while (opt != 3);
  231.  
  232.     delete[]p;
  233.  
  234.     return 0;
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement