sandra0309

ATM

Mar 18th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. #include <iostream>
  2. #include<cstring>
  3.  
  4. using namespace std;
  5. class Smetka
  6. { private:
  7. char brojnasmetka;
  8. char pin;
  9. float sostojba;
  10. public:
  11. Smetka (){}
  12. Smetka (char *brojnasmetka,char *pin,float sostojba)
  13. {
  14. strcpy(this->brojnasmetka,brojnasmetka);
  15. strcpy(this->pin,pin);
  16. this->sostojba=sostojba;
  17.  
  18.  
  19. }
  20. char getBrojnasmetka()
  21. {
  22. return this->brojnasmetka;
  23. }
  24. void setBrojnasmetka(char brojnasmetka)
  25. {
  26. strcpy(this->brojnasmetka,brojnasmetka);
  27. }
  28. char getPin()
  29. {
  30. return this->pin;
  31. }
  32. void setPin(char pin)
  33. {
  34. strcpy(this->pin,pin);
  35. }
  36. float getSostojba ()
  37. {
  38. return this->sostojba;
  39.  
  40. }
  41. void setSostojba(float sostojba)
  42. {
  43. strcpy(this->sostojba,sostojba);
  44. }
  45. bool proverka(char pin)
  46. {
  47. if(this->pin==pin)
  48. return true;
  49. else
  50. return false;
  51. }
  52. void izvadiPari(int iznos)
  53. {
  54. if(iznos<=this->sostojba)
  55. this->sostojba-=iznos;
  56. else
  57. cout<<"Nemate dovolno sretstva"<<endl;
  58. }
  59. };
  60. class Korisnik
  61. {
  62. private:
  63. char imePrezime;
  64. Smetka s;
  65. public:
  66. Korisnik (){}
  67. Korisnik(char imePrezime,Smetka s)
  68. {
  69. strcpy(this->imePrezime,imePrezime);
  70. this->s=Smetka(s.getBrojnasmetka(),s.getPin(),s.getSostojba())
  71. }
  72. Smetka getS()
  73. {
  74. return this->s;
  75. }
  76. void setS(Smetka s)
  77. {
  78. strcpy(this->s,s);
  79. }
  80. char getImePrezime ()
  81. {
  82. return this->imePrezime;
  83. }
  84. void setImePrezime(char imePrezime)
  85. {
  86. strcpy(this->imePrezime,imePrezime);
  87.  
  88. }
  89.  
  90. };
  91. class Bankomat
  92. {
  93. private:
  94. int Sostojba;
  95. Korisnik k[3];
  96. public:
  97. Bankomat () {}
  98. Bankomat (int sostojba,Korisnik k[3])
  99. {
  100. this->Sostojba=Sostojba;
  101. for(int i=0;i<3;i++)
  102. {
  103. this->k[i]=Korisnik(k[i].getImePrezime(),k[i].getS())
  104. }
  105. }
  106. int getSostojba()
  107. {
  108. return Sostojba;
  109. }
  110. void setSostojba(int Sostojba)
  111. {
  112. this->Sostojba=Sostojba;
  113. }
  114. Korisnik *getK()
  115. {
  116. return this->k;
  117. }
  118. void setK(Korisnik[3])
  119. {
  120. for(int i=0;i<3;i++)
  121. {
  122. this->k[i].setImePrezime(k[i].getImeprezime());
  123. this->k[i].setS(k[i].getS());
  124. }
  125. }
  126. void IzvadiPari(Korisnik k1,char pin,int iznos)
  127. {
  128. if(iznos<=Sostojba)
  129. {
  130. int poz=this->ime(k1);
  131. if(poz!=-1 && this->k[poz].getS().proverka(pin))
  132. {
  133. this->k[poz].getS().izvadiPari(iznos);
  134. }
  135. else
  136. cout<<"Korisnikot ne postoi ili pogreshen pin"<<endl;
  137.  
  138. }
  139. else
  140. cout<<"Bankomatot nema dovolno sretstva"<<endl;
  141. }
  142. int Ime(Korisnik X)
  143. {
  144. for (int i=0;i<3;i++)
  145. {
  146. if(this->k[i].getImePrezime()==X.getImePrezime() && this->k[i].getS().getBrojnasmetka()==X.getS().getBrojnasmetka())
  147. return 1;
  148. else
  149. return -1;
  150. }
  151. }
  152. };
  153. int main()
  154. {
  155. char imePrezime,pin,brojNaSmetka;
  156. int sostojba,iznos;
  157. float sostojbaSmetka;
  158. Korisnik niza[3];
  159. for(int i=0;i<3;i++)
  160. {
  161. cin>>imePrezime>>brojNaSmetka>>pin>>sostojbaSmetka;
  162. Smetka s1(brojNaSmetka,pin,sostojbaSmetka)
  163. this->niza[i]=Korisnik(imePrezime,s1);
  164. }
  165. cin>>sostojba;
  166. Bankomat b(sostojba,niza);
  167. while (1)
  168. {
  169. cin>>imePrezime;
  170. if(imePrezime=="!")
  171. break;
  172. cin>>brojNaSmetka>>pin>>sostojba;
  173. Smetka s(brojNaSmetka,pin,sostojba);
  174. Korisnik A(imePrezime,s);
  175. cin>>iznos;
  176. b.IzvadiPari(A,pin,iznos);
  177. }
  178. return 0;
  179. }
  180.  
  181.  
  182.  
  183. int main()
  184. {
  185. cout << "Hello world!" << endl;
  186. return 0;
  187. }
Advertisement
Add Comment
Please, Sign In to add comment