Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- //вашиот код
- #include<cstring>
- using namespace std;
- class ParkingPlac
- {
- private:
- char adress[20];
- char *id;
- int priceph;
- int profit;
- public:
- ParkingPlac(char *adress=" ",char *id=" ",int priceph=0)
- {
- this->priceph = priceph;
- strncpy(this->adress,adress,20);
- this->id = new char[strlen(id)];
- strncpy(this->id,id,strlen(id));
- this->profit=0;
- }
- ParkingPlac(const ParkingPlac &p)
- {
- strncpy(this->adress,p.adress,20);
- this->priceph = p.priceph;
- this->profit = p.profit;
- this->id=new char[strlen(p.id)];
- strncpy(this->id,p.id,strlen(p.id));
- }
- ~ParkingPlac()
- {
- delete [] id;
- }
- ParkingPlac& operator=(const ParkingPlac& p)
- {
- strncpy(adress,p.adress,20);
- strncpy(id,p.id,strlen(p.id));
- profit=p.profit;
- priceph=p.priceph;
- return *this;
- }
- void platiCasovi(int h)
- {
- profit+=h*priceph;
- }
- bool daliIstaAdresa(ParkingPlac p)
- {
- if(strcmp(adress,p.adress)==0) return true;
- else return false;
- }
- char* getId()
- {
- return id;
- }
- void pecati()
- {
- cout<<id<<" "<<adress;
- if(profit!=0) cout<<" - "<<profit<<" denari"<<endl;
- }
- };
- int main()
- {
- ParkingPlac p[100];
- int n,m;
- char adresa[50],id[50];
- int brojcasovi,cenacas;
- cin>>n;
- for (int i=0; i<n; i++)
- {
- cin.get();
- cin.getline(adresa,50);
- cin>>id>>cenacas;
- ParkingPlac edna(adresa,id,cenacas);
- //povik na operatorot =
- p[i]=edna;
- }
- //plakjanje
- cin>>m;
- for (int i=0; i<m; i++)
- {
- cin>>id>>brojcasovi;
- int findId=false;
- for (int j=0; j<n; j++)
- {
- if (strcmp(p[j].getId(),id)==0)
- {
- p[j].platiCasovi(brojcasovi);
- findId=true;
- }
- }
- if (!findId)
- cout<<"Ne e platen parking. Greshen ID."<<endl;
- }
- cout<<"========="<<endl;
- ParkingPlac pCentar("Cvetan Dimov","C10",80);
- for (int i=0; i<n; i++)
- if (p[i].daliIstaAdresa(pCentar))
- p[i].pecati();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement