Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- using namespace std;
- class Lekar {
- protected:
- int fax;
- char ime[15];
- char prezime[15];
- double p;
- public:
- Lekar() {
- }
- Lekar (const int fax, const char *ime, const char *prezime, const double p) {
- this->fax = fax;
- strcpy(this->ime,ime);
- strcpy(this->prezime,prezime);
- this->p = p;
- }
- Lekar (const Lekar &l) {
- fax = l.fax;
- strcpy(ime,l.ime);
- strcpy(prezime,l.prezime);
- p = l.p;
- }
- Lekar& operator= (const Lekar &l) {
- if (this!=&l) {
- fax = l.fax;
- strcpy(ime,l.ime);
- strcpy(prezime,l.prezime);
- p = l.p;
- }
- return *this;
- }
- void pecati() {
- cout<<fax<<": "<<ime<<" "<<prezime<<endl;
- }
- double plata () {
- return p;
- }
- };
- class MaticenLekar :public Lekar {
- private:
- int brPacienti;
- double *kotizacii;
- public:
- MaticenLekar () {
- this->kotizacii = new double[0];
- }
- MaticenLekar (const Lekar &l, const int brPacienti, const double *kotizacii) : Lekar (l) {
- this->brPacienti = brPacienti;
- this->kotizacii = new double[brPacienti];
- for (int i=0; i<brPacienti; i++) {
- this->kotizacii[i] = kotizacii[i];
- }
- }
- MaticenLekar (const MaticenLekar &ml) {
- fax = ml.fax;
- strcpy(ime,ml.ime);
- strcpy(prezime,ml.prezime);
- p = ml.p;
- brPacienti = ml.brPacienti;
- kotizacii = new double[brPacienti];
- for (int i=0; i<brPacienti; i++) {
- kotizacii[i] = ml.kotizacii[i];
- }
- }
- MaticenLekar& operator=(const MaticenLekar &ml) {
- if (this!=&ml) {
- fax = ml.fax;
- strcpy(ime,ml.ime);
- strcpy(prezime,ml.prezime);
- p = ml.p;
- brPacienti = ml.brPacienti;
- kotizacii = new double[brPacienti];
- for (int i=0; i<brPacienti; i++) {
- kotizacii[i] = ml.kotizacii[i];
- }
- }
- return *this;
- }
- ~MaticenLekar () {
- delete[] kotizacii;
- }
- double prosek () {
- double zbir=0;
- double prosek;
- for (int i=0; i<brPacienti; i++) {
- zbir+=kotizacii[i];
- }
- prosek = zbir/brPacienti;
- return prosek;
- }
- void pecati() {
- Lekar::pecati();
- cout<<"Prosek na kotizacii: "<<prosek()<<endl;
- }
- double plata() {
- return Lekar::plata() + (prosek()*30)/100;
- }
- };
- 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