Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cstring>
- using namespace std;
- class Smetka
- { private:
- char brojnasmetka;
- char pin;
- float sostojba;
- public:
- Smetka (){}
- Smetka (char *brojnasmetka,char *pin,float sostojba)
- {
- strcpy(this->brojnasmetka,brojnasmetka);
- strcpy(this->pin,pin);
- this->sostojba=sostojba;
- }
- char getBrojnasmetka()
- {
- return this->brojnasmetka;
- }
- void setBrojnasmetka(char brojnasmetka)
- {
- strcpy(this->brojnasmetka,brojnasmetka);
- }
- char getPin()
- {
- return this->pin;
- }
- void setPin(char pin)
- {
- strcpy(this->pin,pin);
- }
- float getSostojba ()
- {
- return this->sostojba;
- }
- void setSostojba(float sostojba)
- {
- strcpy(this->sostojba,sostojba);
- }
- bool proverka(char pin)
- {
- if(this->pin==pin)
- return true;
- else
- return false;
- }
- void izvadiPari(int iznos)
- {
- if(iznos<=this->sostojba)
- this->sostojba-=iznos;
- else
- cout<<"Nemate dovolno sretstva"<<endl;
- }
- };
- class Korisnik
- {
- private:
- char imePrezime;
- Smetka s;
- public:
- Korisnik (){}
- Korisnik(char imePrezime,Smetka s)
- {
- strcpy(this->imePrezime,imePrezime);
- this->s=Smetka(s.getBrojnasmetka(),s.getPin(),s.getSostojba())
- }
- Smetka getS()
- {
- return this->s;
- }
- void setS(Smetka s)
- {
- strcpy(this->s,s);
- }
- char getImePrezime ()
- {
- return this->imePrezime;
- }
- void setImePrezime(char imePrezime)
- {
- strcpy(this->imePrezime,imePrezime);
- }
- };
- class Bankomat
- {
- private:
- int Sostojba;
- Korisnik k[3];
- public:
- Bankomat () {}
- Bankomat (int sostojba,Korisnik k[3])
- {
- this->Sostojba=Sostojba;
- for(int i=0;i<3;i++)
- {
- this->k[i]=Korisnik(k[i].getImePrezime(),k[i].getS())
- }
- }
- int getSostojba()
- {
- return Sostojba;
- }
- void setSostojba(int Sostojba)
- {
- this->Sostojba=Sostojba;
- }
- Korisnik *getK()
- {
- return this->k;
- }
- void setK(Korisnik[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,char pin,int iznos)
- {
- if(iznos<=Sostojba)
- {
- int poz=this->ime(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<<"Bankomatot nema dovolno sretstva"<<endl;
- }
- int Ime(Korisnik X)
- {
- for (int i=0;i<3;i++)
- {
- if(this->k[i].getImePrezime()==X.getImePrezime() && this->k[i].getS().getBrojnasmetka()==X.getS().getBrojnasmetka())
- return 1;
- else
- return -1;
- }
- }
- };
- int main()
- {
- char imePrezime,pin,brojNaSmetka;
- int sostojba,iznos;
- float sostojbaSmetka;
- Korisnik niza[3];
- for(int i=0;i<3;i++)
- {
- cin>>imePrezime>>brojNaSmetka>>pin>>sostojbaSmetka;
- Smetka s1(brojNaSmetka,pin,sostojbaSmetka)
- this->niza[i]=Korisnik(imePrezime,s1);
- }
- cin>>sostojba;
- Bankomat b(sostojba,niza);
- while (1)
- {
- cin>>imePrezime;
- if(imePrezime=="!")
- break;
- cin>>brojNaSmetka>>pin>>sostojba;
- Smetka s(brojNaSmetka,pin,sostojba);
- Korisnik A(imePrezime,s);
- cin>>iznos;
- b.IzvadiPari(A,pin,iznos);
- }
- return 0;
- }
- int main()
- {
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment