Advertisement
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[13];
- double pocetnaPlata;
- void copy(const Lekar &l)
- {
- this->faksimil=l.faksimil;
- strcpy(this->ime,l.ime);
- strcpy(this->prezime,l.prezime);
- this->pocetnaPlata=l.pocetnaPlata;
- }
- public:
- Lekar(int faksimil=0, char *ime="" , char*prezime= "" , double pocetnaPlata=0.0)
- {
- this->faksimil=faksimil;
- strcpy(this->ime,ime);
- strcpy(this->prezime,prezime);
- this->pocetnaPlata=pocetnaPlata;
- }
- Lekar(const Lekar &l)
- {
- copy(l);
- }
- Lekar &operator=(const Lekar &l)
- {
- if(this!=&l)
- {
- copy(l);
- }
- return *this;
- }
- double plata()
- {
- return pocetnaPlata;
- }
- void pecati()
- {
- cout<<faksimil<<": "<<ime<<" "<<prezime<<endl;
- }
- };
- class MaticenLekar :public Lekar
- {
- private:
- int pacienti ;
- double *kotizacii;
- void copy(const MaticenLekar &m)
- {
- this->faksimil = m.faksimil;
- strcpy(this->ime,m.ime);
- strcpy(this->prezime,m.prezime);
- this->pocetnaPlata=m.pocetnaPlata;
- this->pacienti = m.pacienti;
- this->kotizacii = new double [this->pacienti];
- for (int i=0;i<pacienti;i++)
- this->kotizacii[i]=m.kotizacii[i];
- }
- public:
- MaticenLekar () : Lekar() {
- pacienti = 0;
- this->kotizacii = new double[0];
- }
- 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)
- {
- copy(m);
- }
- MaticenLekar &operator=(const MaticenLekar &m)
- {
- if(this!=&m){
- delete [] kotizacii;
- copy(m);
- }
- return *this;
- }
- double prosek(){
- double sum = 0.0;
- for (int i=0;i<=pacienti;i++)
- sum+=kotizacii[i];
- return sum/pacienti*1.0;
- }
- double plata()
- {
- return Lekar::plata() + 0.3 * prosek();
- }
- void pecati()
- {
- Lekar::pecati();
- cout<<"Prosek na kotizacii: "<<prosek()<<endl;
- }
- ~MaticenLekar(){delete[]kotizacii;}
- };
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement