Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- using namespace std;
- class Lekar{
- protected:
- int faksimil;
- char ime[10];
- char prezime[15];
- double salary;
- public:
- Lekar(){}
- Lekar(int faksimil, char *ime, char *prezime, double plata){
- this->faksimil = faksimil;
- strcpy(this->ime, ime);
- strcpy(this->prezime,prezime);
- this->salary = plata;
- }
- Lekar(const Lekar &l){
- this->faksimil = l.faksimil;
- strcpy(this->ime, l.ime);
- strcpy(this->prezime, l.prezime);
- this->salary =l.salary;
- }
- double plata(){
- return this->salary;
- }
- void pecati(){
- cout<<faksimil<<": "<<ime<<" "<<prezime<<endl;
- }
- Lekar& operator=(const Lekar &l){
- if (this == &l)
- return *this;
- this->faksimil = l.faksimil;
- strcpy(this->ime, l.ime);
- strcpy(this->prezime, l.prezime);
- this->salary = l.salary;
- return *this;
- }
- };
- class MaticenLekar: public Lekar{
- protected:
- int pacienti;
- double *kotizacii;
- public:
- MaticenLekar(){}
- MaticenLekar(Lekar L, int pacienti,double *kotizacii):Lekar(L)
- {
- this->pacienti = pacienti;
- this->kotizacii = new double[pacienti];
- for(int i = 0; i<pacienti ; i++){
- this->kotizacii[i] = kotizacii[i];
- }
- }
- MaticenLekar(const MaticenLekar &m){
- this->faksimil = m.faksimil;
- strcpy(this->ime,m.ime);
- strcpy(this->prezime, m.prezime);
- this->salary = m.salary;
- this->pacienti = m.pacienti;
- this->kotizacii = new double[pacienti];
- for(int i=0 ; i<pacienti ; i++){
- this->kotizacii[i] = m.kotizacii[i];
- }
- }
- MaticenLekar& operator=(const MaticenLekar &m){
- if(this == &m)
- return *this;
- this->faksimil = m.faksimil;
- strcpy(this->ime,m.ime);
- strcpy(this->prezime, m.prezime);
- this->salary = m.salary;
- delete [] kotizacii;
- this->pacienti = m.pacienti;
- this->kotizacii = new double[pacienti];
- for(int i=0 ; i<pacienti ; i++){
- this->kotizacii[i] = m.kotizacii[i];
- }
- return *this;
- }
- ~MaticenLekar(){
- delete [] kotizacii;
- }
- double prosek(){
- double zbir;
- for(int i= 0 ; i<pacienti; i++){
- zbir += kotizacii[i];
- }
- return zbir/pacienti*1.0;
- }
- double plata(){
- return Lekar::plata() + 0.3 *prosek();
- }
- void pecati(){
- Lekar::pecati();
- cout<<"Prosek na kotizacii: "<<prosek()<<endl;
- }
- };
- int main() {
- int n;
- cin>>n;
- int pacienti;
- double kotizacii[100];
- int faksimil;
- char ime [20];
- char prezime [20];
- double osnovnaPlata;
- Lekar * lekari = new Lekar [n];
- MaticenLekar * maticni = new MaticenLekar [n];
- for (int i=0;i<n;i++){
- cin >> faksimil >> ime >> prezime >> osnovnaPlata;
- lekari[i] = Lekar(faksimil,ime,prezime,osnovnaPlata);
- }
- for (int i=0;i<n;i++){
- cin >> pacienti;
- for (int j=0;j<pacienti;j++){
- cin >> kotizacii[j];
- }
- maticni[i]=MaticenLekar(lekari[i],pacienti,kotizacii);
- }
- int testCase;
- cin>>testCase;
- if (testCase==1){
- cout<<"===TESTIRANJE NA KLASATA LEKAR==="<<endl;
- for (int i=0;i<n;i++){
- lekari[i].pecati();
- cout<<"Osnovnata plata na gorenavedeniot lekar e: "<<lekari[i].plata()<<endl;
- }
- }
- else {
- cout<<"===TESTIRANJE NA KLASATA MATICENLEKAR==="<<endl;
- for (int i=0;i<n;i++){
- maticni[i].pecati();
- cout<<"Platata na gorenavedeniot maticen lekar e: "<<maticni[i].plata()<<endl;
- }
- }
- delete [] lekari;
- delete [] maticni;
- return 0;
- }
Add Comment
Please, Sign In to add comment