Advertisement
uberzawadaog

projekt2_main

Oct 6th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.42 KB | None | 0 0
  1. #include "projekt_2.h"
  2.  
  3. const int SIZE=5;
  4.  
  5. int main()
  6. {
  7.     using std::string;
  8.     using std::cout;
  9.     using std::cin;
  10.     using std::endl;
  11.     using std::strchr;
  12.  
  13.     char ch1;
  14.     int ch3;
  15.     string tempname;
  16.     string tempsurname;
  17.     double tempPESEL;
  18.     double tempNIP;
  19.     int i=0;
  20.     Worker *tab[SIZE];
  21.  
  22.     cout << "wcisnij d aby dodac pracownika, w aby wyliczyc zarobki, p aby wypisac pracownikow, inny dowolny klawisz aby zakonczyc: " <<endl;
  23.     cin >> ch1;
  24.     while(strchr("dwp",ch1)){
  25.  
  26.     switch(ch1){
  27.  
  28.         case 'd':
  29.             if(i<6){
  30.                 cout << "podaj imie: ";
  31.                 cin >> tempname;
  32.                 cout << "podaj nazwisko: ";
  33.                 cin >> tempsurname;
  34.                 cout << "podaj PESEL: ";
  35.                 cin >> tempPESEL;
  36.                 cout << "podaj NIP: ";
  37.                 cin >> tempNIP;
  38.                 cout << "podaj typ pracownika - r dla RegularWorker, f dla freelancer, t dla tradesman: ";
  39.                 cin >> ch1;
  40.        
  41.                 while(strchr("rft",ch1)==NULL){
  42.  
  43.                     cout << "nieodpowiedni typ pracownika - podaj r, f lub t" <<endl;
  44.                     cin >> ch1;
  45.                 }
  46.  
  47.                 switch(ch1){
  48.  
  49.                     case 'r' : tab[i]=new RegularWorker(tempname, tempsurname, tempPESEL, tempNIP);
  50.                             break;
  51.  
  52.                     case 'f' : tab[i]=new Freelancer(tempname, tempsurname, tempPESEL, tempNIP);
  53.                             break;
  54.  
  55.                     case 't' : tab[i]=new Tradesman(tempname, tempsurname, tempPESEL, tempNIP);
  56.                             break;
  57.                 }
  58.                 ++i;
  59.             }
  60.             else
  61.                 cout << "max ilosc slotow osiagnieta" <<endl;
  62.             break;
  63.  
  64.         case 'w' :
  65.                 cout << "podaj nr pracownika: ";
  66.                 cin >> ch3;
  67.                 tab[ch3-1]->wylicz_zarobki();
  68.                 break;
  69.  
  70.         case 'p' :
  71.                 for(int j=0; j<i; ++j){
  72.                     cout << j+1 << ". " <<endl;
  73.                     tab[j]->print();
  74.                     cout <<endl;
  75.                 }
  76.                 break;
  77.         }
  78.         cout << "wcisnij d aby dodac pracownika, w aby wyliczyc zarobki, p aby wypisac pracownikow, inny dowolny klawisz aby zakonczyc:" <<endl;
  79.         cin >> ch1;
  80.     }
  81.     for(int j=0; j<i; ++j)
  82.         delete tab[j];
  83.  
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement