Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Smetka
- {
- private:
- string brojSmetka;
- string pin;
- float sostojba;
- public:
- Smetka()
- {
- this->brojSmetka="";
- this->pin="";
- this->sostojba=0;
- }
- Smetka(string brojSmetka, string pin, float sostojba)
- {
- this->brojSmetka=brojSmetka;
- this->pin=pin;
- this->sostojba=sostojba;
- }
- string getBrojSmetka()
- {
- return this->brojSmetka;
- }
- void setBrojSmetka(string brojSmetka)
- {
- this->brojSmetka=brojSmetka;
- }
- string getPin()
- {
- return this->pin;
- }
- void setPin(string pin)
- {
- this->pin=pin;
- }
- float getSostojba()
- {
- return this->sostojba;
- }
- void setSostojba(float sostojba)
- {
- this->sostojba=sostojba;
- }
- // PECATI
- void pecatiSmetka ()
- {
- cout<<" Broj na smetka: "<< this->brojSmetka<< endl;
- cout<<"Pin: "<< this->pin<<endl;
- cout<<"Sostojba: "<<this->sostojba<<endl;
- }
- bool proverka(string pin)
- {
- if(this->pin==pin)
- return true;
- return false;
- }
- void IzvadiPari(int iznos)
- {
- if(iznos<=sostojba)
- {
- this->sostojba-=iznos;
- cout<<"Novata sostojba na vasata smetka e : "<<this->sostojba<< endl;
- }
- else
- {
- cout<<"Nemate dovolno sredstva"<<endl;
- }
- }
- }; // kraj na klasa Smetka
- class Korisnik
- {
- private:
- string imePrezime;
- Smetka s;
- public:
- Korisnik()
- {
- this->imePrezime="";
- this->s=Smetka();
- }
- Korisnik(string imePrezime, Smetka s)
- {
- this->imePrezime=imePrezime;
- this->s=Smetka(s.getBrojSmetka(),s.getPin(),s.getSostojba());
- }
- string getImePrezime()
- {
- return this->imePrezime;
- }
- void setImePrezime(string imePrezime)
- {
- this->imePrezime=imePrezime;
- }
- Smetka getS()
- {
- return this->s;
- }
- void setS(Smetka s)
- {
- this->s.setBrojSmetka(s.getBrojSmetka());
- this->s.setPin(s.getPin());
- this->s.setSostojba(s.getSostojba());
- }
- //PECATI
- void pecatiKorisnik ()
- {
- cout<<"Ime i prezime na korisnikot: "<<this->imePrezime<<endl;
- cout<<"Podatoci za smetkata na korisnikot: ";
- s.pecatiSmetka();
- }
- };// kraj na klasa Korisnik
- class Bankomat
- {
- private:
- int sostojba;
- Korisnik k[3];
- int ima(Korisnik x)
- {
- for(int i=0; i<3; i++)
- {
- if(this->k[i].getImePrezime() == x.getImePrezime() && this->k[i].getS().getBrojSmetka() == x.getS().getBrojSmetka())
- return i;
- }
- return -1;
- }
- public:
- Bankomat()
- {
- this->sostojba=0;
- int n;
- for(int i=0; i<n; i++)
- {
- this->k[i]=Korisnik();
- }
- }
- Bankomat(int sostojba, Korisnik k[3])
- {
- this->sostojba=sostojba;
- int n;
- for(int i=0; i<n; i++)
- {
- this->k[i]=Korisnik(k[i].getImePrezime(), k[i].getS());
- }
- }
- int getSostojba()
- {
- return this->sostojba;
- }
- void setSostojba(int sostojba)
- {
- this->sostojba=sostojba;
- }
- Korisnik *getK()
- {
- return this->k;
- }
- void setK(Korisnik k[3])
- {
- for(int i=0; i<3; i++)
- {
- this->k[i].setImePrezime(k[i].getImePrezime());
- this->k[i].setS(k[i].getS());
- }
- }
- void IzvadiPari(Korisnik k1, string pin, int iznos)
- {
- if(iznos<=sostojba)
- {
- int poz=this->ima(k1);
- if(poz!=-1 && this->k[poz].getS().proverka(pin))
- {
- this->k[poz].getS().IzvadiPari(iznos);
- }
- else
- {
- cout<<"Korisnikot ne postoi ili Pogreshen pin"<<endl;
- };
- else
- {
- cout<<"Nema dovolno sredstva"<<endl;
- }
- }
- }
- // PECATI
- void pecatiBankomat(int n)
- {
- cout<<"Sostojbata na bankomatot e: "<<sostojba<<endl;
- cout<<"Listata na korisnci e: ";
- for(int i=0; i<n;i++)
- {
- k[i].pecatiKorisnik();
- }
- }
- }; // kraj na klasa Bankomat
- int main()
- {
- string imePrezime, pin;
- int iznos, sostojba;
- float sostojbaS; //sostojba na smetka
- Korisnik niza[3];
- for(i=0; i<3; i++)
- {
- cin>>imePrezime>>brojSmetka>>pin>>sostojbaS;
- Smetka s1(brojSmetka, pin, sostojbaS);
- this->k[i]=Korisnik(imePrezime, s1);
- }
- cin>>sostojba;
- Bankomat b(sostojba, niza)
- while(1)
- {
- cin>>imePrezime;
- if(imePrezime=="!")
- break;
- cin>>brojSmetka>>pin>>sostojba;
- Smetka s(brojSmetka,pin,sostojba);
- Korisnik A(imePrezime, s);
- cin>>iznos;
- b.IzvadiPari(A,pin,iznos);
- }
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement