Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. // Person mora imati Ime, prezime, oib
  6. // get imena, prezimena, oiba; privatni set imena, prezimena, oiba
  7. // Osoba neka ima instancu Account klase
  8.  
  9. // BankAccount mora imati IBAN, balance
  10. // public get iban, balance; public withdraw, deposit, IBAN - inicijalizaciju u konstruktoru
  11.  
  12. // Banka mora sadrzavati osobe i racune te mogucnost dodavanja istih
  13. // vector korisnika, mogucnost dodavanja novih korisnika, provjeru IBAN-a(ne smiju 2 ista biti)
  14. // Mogucnost pretrazivanja korisnika i printanje IBAN-a i trenutnog stanja racuna.
  15.  
  16.  
  17. // Zadatak:
  18. // napraviti program pomocu kojega korisnik moze dodavati nove klijente za banku
  19. // Mogucnost dodavanja i skidanja sredstava sa racuna
  20. // Program neka ima podrsku za dodavanje beskonacno mnogo klijenata.
  21.  
  22. using namespace std;
  23. class BankAccount
  24. {
  25. public:
  26. BankAccount(string iban)
  27. {
  28. balance = 0.00f;
  29. }
  30. ~BankAccount() {};
  31.  
  32. void withdraw(double ammount)
  33. {
  34. balance -= ammount;
  35. }
  36.  
  37. void deposit(double ammount)
  38. {
  39. balance += ammount;
  40. }
  41.  
  42. string getIban()
  43. {
  44. return IBAN;
  45. }
  46.  
  47. double getBalance()
  48. {
  49. return balance;
  50. }
  51. private:
  52. double balance;
  53. std::string IBAN;
  54. };
  55.  
  56. class Person
  57. {
  58. public:
  59. Person(string eName, string eLastName, string eOIB, BankAccount* eAccount)
  60. {
  61. name = eName;
  62. lastName = eLastName;
  63. oib = eOIB;
  64. account = eAccount;
  65. }
  66. ~Person() {}
  67. BankAccount* account;
  68.  
  69. string getName()
  70. {
  71. return name;
  72. }
  73.  
  74. string getLastName()
  75. {
  76. return lastName;
  77. }
  78.  
  79. string getOib()
  80. {
  81. return oib;
  82. }
  83.  
  84. private:
  85. string name;
  86. string lastName;
  87. string oib;
  88.  
  89. };
  90.  
  91. //
  92. //
  93. //class Bank
  94. //{
  95. //public:
  96. // Bank();
  97. // ~Bank();
  98. //
  99. // Person* getUser(string name)
  100. // {
  101. // for (auto it : users)
  102. // {
  103. // if (name == it.getName())
  104. // {
  105. // return &it;
  106. // }
  107. // }
  108. // cout << "User doesnt exist!" << endl;
  109. // return nullptr;
  110. // }
  111. //
  112. // vector<Person> getUsers()
  113. // {
  114. // return users;
  115. // }
  116. //
  117. // void addUser()
  118. // {
  119. // string eName, eLastName, eOIB;
  120. // BankAccount* eAccount = createBankAccount();
  121. // cout << "Enter name: " << endl;
  122. // cin >> eName;
  123. //
  124. // cout << "Enter last name: " << endl;
  125. // cin >> eLastName;
  126. //
  127. // cout << "Enter oib: " << endl;
  128. // cin >> eOIB;
  129. //
  130. // if (checkForOib(eOIB))
  131. // {
  132. // //users.push_back(Person(eName, eLastName, eOIB, *eAccount));
  133. // }
  134. // else
  135. // {
  136. // cout << "User not created, missing " << "" << endl;
  137. // }
  138. //
  139. // }
  140. //
  141. // bool checkForOib(string eOib)
  142. // {
  143. // for (auto it : users)
  144. // {
  145. // if (eOib == it.getOib())
  146. // {
  147. // return false;
  148. // }
  149. // }
  150. // return true;
  151. // }
  152. // void withdrawFromAccount(string name, double ammount)
  153. // {
  154. // for (auto it : users)
  155. // {
  156. // if (name == it.getName())
  157. // {
  158. // (it.account)->withdraw(ammount);
  159. // }
  160. // }
  161. // }
  162. //
  163. // void depositToAccount(string name, double ammount)
  164. // {
  165. // for (auto it : users)
  166. // {
  167. // if (name == it.getName())
  168. // {
  169. // (it.account)->deposit(ammount);
  170. // }
  171. // }
  172. // }
  173. //
  174. //private:
  175. // vector<Person> users;
  176. // BankAccount* createBankAccount()
  177. // {
  178. // return new BankAccount("HR041234567891011");
  179. //
  180. //
  181. //};
  182. //
  183. int main()
  184. {
  185. //Bank pbz;
  186. BankAccount* temp = new BankAccount("");
  187. Person* osoba = new Person("sd", "ds", "ds", temp);
  188. osoba->account->deposit(10);
  189. cout << osoba->account->getBalance() << endl;
  190. /*
  191. while (true)
  192. {
  193. string choice;
  194. cout << " 1 - novi korisnik " << endl;
  195. cout << " 2 - deposit " << endl;
  196. cout << " 3 - withdraw" << endl;
  197. cout << " 4 - izlaz" << endl;
  198. cin >> choice;
  199. if (choice == "1")
  200. {
  201. pbz.addUser();
  202. }
  203. else if (choice == "2")
  204. {
  205. pbz.depositToAccount("", 30);
  206. }
  207. else if (choice == "3")
  208. {
  209. pbz.depositToAccount("", 30);
  210. }
  211. else if (choice == "4")
  212. {
  213. break;
  214. }
  215. }*/
  216. system("pause");
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement