Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "projekt_2.h"
- const int SIZE=5;
- int main()
- {
- using std::string;
- using std::cout;
- using std::cin;
- using std::endl;
- using std::strchr;
- char ch1;
- int ch3;
- string tempname;
- string tempsurname;
- double tempPESEL;
- double tempNIP;
- int i=0;
- Worker *tab[SIZE];
- cout << "wcisnij d aby dodac pracownika, w aby wyliczyc zarobki, p aby wypisac pracownikow, inny dowolny klawisz aby zakonczyc: " <<endl;
- cin >> ch1;
- while(strchr("dwp",ch1)){
- switch(ch1){
- case 'd':
- if(i<6){
- cout << "podaj imie: ";
- cin >> tempname;
- cout << "podaj nazwisko: ";
- cin >> tempsurname;
- cout << "podaj PESEL: ";
- cin >> tempPESEL;
- cout << "podaj NIP: ";
- cin >> tempNIP;
- cout << "podaj typ pracownika - r dla RegularWorker, f dla freelancer, t dla tradesman: ";
- cin >> ch1;
- while(strchr("rft",ch1)==NULL){
- cout << "nieodpowiedni typ pracownika - podaj r, f lub t" <<endl;
- cin >> ch1;
- }
- switch(ch1){
- case 'r' : tab[i]=new RegularWorker(tempname, tempsurname, tempPESEL, tempNIP);
- break;
- case 'f' : tab[i]=new Freelancer(tempname, tempsurname, tempPESEL, tempNIP);
- break;
- case 't' : tab[i]=new Tradesman(tempname, tempsurname, tempPESEL, tempNIP);
- break;
- }
- ++i;
- }
- else
- cout << "max ilosc slotow osiagnieta" <<endl;
- break;
- case 'w' :
- cout << "podaj nr pracownika: ";
- cin >> ch3;
- tab[ch3-1]->wylicz_zarobki();
- break;
- case 'p' :
- for(int j=0; j<i; ++j){
- cout << j+1 << ". " <<endl;
- tab[j]->print();
- cout <<endl;
- }
- break;
- }
- cout << "wcisnij d aby dodac pracownika, w aby wyliczyc zarobki, p aby wypisac pracownikow, inny dowolny klawisz aby zakonczyc:" <<endl;
- cin >> ch1;
- }
- for(int j=0; j<i; ++j)
- delete tab[j];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement