Advertisement
Andrey_ZoZ

Untitled

Sep 25th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.06 KB | None | 0 0
  1. #include<iostream>
  2. #include <fstream>
  3. #include <string>
  4. class MessageOperation
  5. {
  6. private:
  7. std::string message;
  8. public:
  9. MessageOperation(std::string message):message{message}{std::cout<<message;}
  10. };
  11.  
  12. class FinanceSystemZozInc
  13. {
  14. private:
  15. static int idsWallets;
  16. static int idsDebitCards;
  17. static int idsCreditCards;
  18. protected:
  19. //Clases
  20. class WalletZozInc
  21. {
  22. private:
  23. int id{idsWallets++};
  24. std::string _nameOfOwnerOfWallet;
  25. std::string _nameOfWallet;
  26. long double _money;
  27. public:
  28. //Constructs
  29. WalletZozInc(std::string nameOfOwnerOfWallet):_nameOfOwnerOfWallet{nameOfOwnerOfWallet},_nameOfWallet{"WalletZozInc"},_money{0}
  30. {MessageOperation("\tHello,you make wallet in ZozInc\n");}
  31.  
  32. WalletZozInc(char* nameOfOwnerOfWallet):_nameOfOwnerOfWallet{nameOfOwnerOfWallet},_nameOfWallet{"WalletZozInc"},_money{0}
  33. {MessageOperation("\tHello,you make wallet in ZozInc\n");}
  34.  
  35. WalletZozInc():_nameOfOwnerOfWallet{"ZozInc"},_nameOfWallet{"WalletZozInc"},_money{0}{};
  36.  
  37. //Methods_Sets
  38. void changeNameOfWallet(std::string nameOfWallet){_nameOfWallet=nameOfWallet;MessageOperation("Name of wallet was changed!\n");}
  39.  
  40. void changeNameOfWallet(char* nameOfWallet){_nameOfWallet=nameOfWallet;MessageOperation("Name of wallet was changed!\n");}
  41.  
  42. void addMoney(long double money,std::string aboutOperation="No add. information")
  43. {_money+=money;MessageOperation((std::string)aboutOperation);std::cout<<"\n";}//Проверить на вывод
  44.  
  45. void minucMoney(long double money,std::string aboutOperation="No add. information"){
  46. if(money>_money){MessageOperation("Error...low balance\n");}
  47. else{_money-=money;MessageOperation((std::string)aboutOperation);std::cout<<"\n";}
  48. }
  49.  
  50. //Methods_Gets(Stats)
  51. void showMyWallet(){std::cout<<"\t\t"<<_nameOfWallet<<"\n"<<"Owner = "<<_nameOfOwnerOfWallet<<"\n"<<"Money = "<<_money<<"\nGood luck, your ZozInc\n";}
  52.  
  53. int getId(){return id;}
  54.  
  55. std::string getNameOfOwnerOfWallet(){return _nameOfOwnerOfWallet;}
  56.  
  57. std::string getNameOfWallet(){return _nameOfWallet;}
  58.  
  59. long double getMoney(){return _money;}
  60.  
  61. //Operators
  62. void operator=(WalletZozInc& object)
  63. {
  64. id=object.getId();
  65. _nameOfOwnerOfWallet=object.getNameOfOwnerOfWallet();
  66. _nameOfWallet=object.getNameOfWallet();
  67. _money=object.getMoney();
  68. }
  69.  
  70. //Admin methods
  71. void changeNameOfOwnerOfWallet(std::string nameOfOwnerOfWallet,std::string pass) { if(pass=="AdminKey"){_nameOfOwnerOfWallet=nameOfOwnerOfWallet;} }
  72.  
  73. void changeNameOfOwnerOfWallet(char* nameOfOwnerOfWallet,std::string pass) { if(pass=="AdminKey"){_nameOfOwnerOfWallet=nameOfOwnerOfWallet;} }
  74.  
  75. void changeMoney(long double countMoney,std::string pass){if(pass=="AdminKey"){_money=countMoney;} }
  76.  
  77. void changeId(int id,std::string pass){if(pass=="AdminKey"){this->id=id;}}
  78. };
  79.  
  80. class DebitCardZozInc
  81. {
  82. private:
  83. int id{idsDebitCards++};
  84. std::string _nameOfOwnerOfDebitCard;
  85. std::string _nameOfDebitCard;
  86. long double _money;
  87. public:
  88. //Constructs
  89. DebitCardZozInc(std::string nameOfOwnerOfDebitCard):_nameOfOwnerOfDebitCard{nameOfOwnerOfDebitCard},_nameOfDebitCard{"DebitCardZozInc"},_money{0}{MessageOperation("\tHello, you make debit card in ZozInc\n");}
  90.  
  91. DebitCardZozInc(char* nameOfOwnerOfDebitCard):_nameOfOwnerOfDebitCard{nameOfOwnerOfDebitCard},_nameOfDebitCard{"DebitCardZozInc"},_money{0}{MessageOperation("\tHello, you make debit card in ZozInc\n");}
  92.  
  93. DebitCardZozInc():_nameOfOwnerOfDebitCard{"ZozInc"},_nameOfDebitCard{"DebitCardZozInc"},_money{0}{};
  94.  
  95. //Methods_Sets
  96. void changeNameOfDebitCard(std::string nameOfDebitCard) {_nameOfDebitCard=nameOfDebitCard;MessageOperation("Name of debit card was changed!");}
  97.  
  98. void changeNameOfDebitCard(char* nameOfDebitCard) {_nameOfDebitCard=nameOfDebitCard;MessageOperation("Name of debit card was changed!");}
  99.  
  100. void addMoney(long double money,std::string aboutOperation="No add. information")
  101. {
  102. int number;
  103. std::cout<<"Сommission = "<<_money*0.005<<".For complete operation enter 1, for stop operation enter antoher number.\nNumber = ";
  104. std::cin>>number;
  105. if(number==1) {_money+=money-_money*0.005;MessageOperation((std::string)aboutOperation);std::cout<<"\n";}
  106. else{MessageOperation("Operation not completed\n");}
  107. }//Проверить на вывод
  108.  
  109. void minucMoney(long double money,std::string aboutOperation="No add. information")
  110. {
  111. int number;
  112. std::cout<<"Сommission = "<<_money*0.010<<".For complete operation enter 1, for stop operation enter antoher number.\nNumber = ";
  113. std::cin>>number;
  114. if(number==1){ if(money>_money){MessageOperation("Error...low balance\n");} else{_money-=money;MessageOperation((std::string)aboutOperation);std::cout<<"\n";}}
  115. else{MessageOperation("Operation not completed\n");}
  116. }
  117.  
  118. //Methods_Gets
  119. void showMyDebitCard() {std::cout<<"\t\t"<<_nameOfDebitCard<<"\n"<<"Owner = "<<_nameOfOwnerOfDebitCard<<"\n"<<"Money = "<<_money<<"\nGood luck, your ZozInc\n";}
  120.  
  121. int getId(){return id;}
  122.  
  123. std::string getNameOfOwnerOfDebitCard(){return _nameOfOwnerOfDebitCard;}
  124.  
  125. std::string getNameOfDebitCard(){return _nameOfDebitCard;}
  126.  
  127. long double getMoney(){return _money;}
  128.  
  129. //Operators
  130. void operator=(DebitCardZozInc& object)
  131. {
  132. id=object.getId();
  133. _nameOfOwnerOfDebitCard=object.getNameOfOwnerOfDebitCard();
  134. _nameOfDebitCard=object.getNameOfDebitCard();
  135. _money=object.getMoney();
  136. }
  137.  
  138. //Admin methods
  139. void changeNameOfOwnerOfDebitCard(std::string nameOfOwnerOfDebitCard,std::string pass) { if(pass=="AdminKey"){_nameOfOwnerOfDebitCard=nameOfOwnerOfDebitCard;} }
  140.  
  141. void changeNameOfOwnerOfDebitCard(char* nameOfOwnerOfDebitCard,std::string pass) { if(pass=="AdminKey"){_nameOfOwnerOfDebitCard=nameOfOwnerOfDebitCard;} }
  142.  
  143. void changeMoney(long double countMoney,std::string pass){if(pass=="AdminKey"){_money=countMoney;} }
  144.  
  145. void changeId(int id,std::string pass){if(pass=="AdminKey"){this->id=id;}}
  146. };
  147.  
  148. class CreditCardZozInc
  149. {
  150. private:
  151. int id{idsCreditCards++};
  152. std::string _nameOfOwnerOfCreditCard;
  153. std::string _nameOfCreditCard;
  154. long double _money;
  155. long double _creditLimit;
  156. public:
  157. //Constructs
  158. CreditCardZozInc(std::string nameOfOwnerOfCreditCard):_nameOfOwnerOfCreditCard{nameOfOwnerOfCreditCard},_nameOfCreditCard{"CreditCardZozInc"},_money{0},_creditLimit{0}{MessageOperation("\tHello,you make credit card in ZozInc\n");}
  159.  
  160. CreditCardZozInc(char* nameOfOwnerOfCreditCard):_nameOfOwnerOfCreditCard{nameOfOwnerOfCreditCard},_nameOfCreditCard{"CreditCardZozInc"},_money{0},_creditLimit{0}{MessageOperation("\tHello,you make credit card in ZozInc\n");}
  161.  
  162. CreditCardZozInc():_nameOfOwnerOfCreditCard{"ZozInc"},_nameOfCreditCard{"CreditCardZozInc"},_money{0},_creditLimit{0}{}
  163.  
  164. //Methods_Sets
  165. void changeNameOfCreditCard(std::string nameOfCreditCard){_nameOfCreditCard=nameOfCreditCard;MessageOperation("Name of credit card was changed!");}
  166.  
  167. void changeNameOfCreditCard(char* nameOfCreditCard){_nameOfCreditCard=nameOfCreditCard;MessageOperation("Name of credit card was changed!");}
  168.  
  169. void addMoney(long double money,std::string aboutOperation="No add. information"){if(_creditLimit>0){if(money>_creditLimit){money-=_creditLimit;_creditLimit=0;}else{_creditLimit-=money;money=0;}}_money+=money;MessageOperation((std::string)aboutOperation);}
  170.  
  171. void minucMoney(long double money,std::string aboutOperation="No add. information"){
  172. int number;
  173. std::cout<<"Сommission = "<<_money*0.15<<".For complete operation enter 1, for stop operation enter antoher number.\nNumber = ";
  174. std::cin>>number;
  175. if(number==1){ if(money>_money){MessageOperation("Error...low balance\n");} else{_money-=money;MessageOperation((std::string)aboutOperation);std::cout<<"\n";}}
  176. else{MessageOperation("Operation not completed\n");} }
  177.  
  178. //Methods_Gets
  179. void showMyCreditCard(){std::cout<<"\t\t"<<_nameOfCreditCard<<"\n"<<"Owner = "<<_nameOfOwnerOfCreditCard<<"\n"<<"Money = "<<_money<<"\nCredit limit = "<<_creditLimit<<"\nGood luck, your ZozInc\n";}
  180.  
  181. int getId(){return id;}
  182.  
  183. std::string getNameOfOwnerOfCreditCard(){return _nameOfOwnerOfCreditCard;}
  184.  
  185. std::string getNameOfCreditCard(){return _nameOfCreditCard;}
  186.  
  187. long double getMoney(){return _money;}
  188.  
  189. long double getCreditLimit(){return _creditLimit;}
  190.  
  191. //Operators
  192. void operator=(CreditCardZozInc& object)
  193. {
  194. id=object.getId();
  195. _nameOfOwnerOfCreditCard=object.getNameOfOwnerOfCreditCard();
  196. _nameOfCreditCard=object.getNameOfCreditCard();
  197. _money=object.getMoney();
  198. }
  199.  
  200. //Admin methods
  201. void changeNameOfOwnerOfCreditCard(std::string nameOfOwnerOfCreditCard,std::string pass) { if(pass=="AdminKey"){_nameOfOwnerOfCreditCard=nameOfOwnerOfCreditCard;} }
  202.  
  203. void changeNameOfOwnerOfCardCard(char* nameOfOwnerOfCreditCard,std::string pass) { if(pass=="AdminKey"){_nameOfOwnerOfCreditCard=nameOfOwnerOfCreditCard;} }
  204. //zzzjhjggjjhnhmmbmmbmbmfdfgkjsdfh
  205. void changeMoney(long double countMoney,std::string pass){if(pass=="AdminKey"){_money=countMoney;} }
  206.  
  207. void changeCreditLimit(long double countCreditMoney,std::string pass){if(pass=="AdminKey"){_creditLimit=countCreditMoney;}}
  208.  
  209. void changeId(int id, std::string pass){if(pass=="AdminKey"){this->id=id;}}
  210.  
  211. //Credit Limit
  212. void receiveCreditMoney(long double number){if(_creditLimit==0){_money+=number;_creditLimit=number+number*0.2;MessageOperation("Operation completed\n");}else{MessageOperation("You have credit\n");}}
  213.  
  214. void returnCreditMoney(){if(_money<_creditLimit){_creditLimit-=_money;_money=0;MessageOperation("Operation completed");}else{_money-=_creditLimit;_creditLimit=0;MessageOperation("Operation completed");}}
  215. };
  216. private:
  217. std::string _FNLN;
  218. std::string _passwordToFinanceSystem;
  219. int _countWallets;
  220. int _countDebitCards;
  221. int _countCreditCards;
  222. WalletZozInc* wallet;
  223. DebitCardZozInc* debitCard;
  224. CreditCardZozInc* creditCard;
  225. public:
  226. //Constructs
  227. FinanceSystemZozInc(std::string FNLN,std::string passwordToFinanceSystem)
  228. :_FNLN{FNLN},_passwordToFinanceSystem{passwordToFinanceSystem}, _countWallets{0}, _countDebitCards{0}, _countCreditCards{0}{}
  229.  
  230. FinanceSystemZozInc(char* FNLN,char* passwordToFinanceSystem)
  231. :_FNLN{FNLN},_passwordToFinanceSystem{passwordToFinanceSystem}, _countWallets{0}, _countDebitCards{0}, _countCreditCards{0}{}
  232.  
  233. FinanceSystemZozInc(char* FNLN,std::string passwordToFinanceSystem)
  234. :_FNLN{FNLN},_passwordToFinanceSystem{passwordToFinanceSystem}, _countWallets{0}, _countDebitCards{0}, _countCreditCards{0}{}
  235.  
  236. FinanceSystemZozInc(std::string FNLN,char* passwordToFinanceSystem)
  237. :_FNLN{FNLN},_passwordToFinanceSystem{passwordToFinanceSystem}, _countWallets{0}, _countDebitCards{0}, _countCreditCards{0}{}
  238.  
  239. //Destruct
  240. /*~FinanceSystemZozInc(){delete[] wallet;delete[] debitCard; delete[] creditCard;_countWallets=0;_countDebitCards=0;_countCreditCards=0;}*/
  241.  
  242. //Methods_Create Cards/Wallets
  243. void createWallet(std::string FNLN){
  244. WalletZozInc* test=new WalletZozInc[_countWallets];
  245. for(int index{0};index<_countWallets;++index){test[index]=wallet[index];}
  246. ++_countWallets;
  247. wallet=new WalletZozInc[_countWallets];
  248. for(int index{0};index<_countWallets-1;++index){wallet[index]=test[index];}
  249. wallet[_countWallets-1].changeNameOfOwnerOfWallet(FNLN, "AdminKey");
  250. };
  251. void createWallet(char* FNLN){
  252. WalletZozInc* test=new WalletZozInc[_countWallets];
  253. for(int index{0};index<_countWallets;++index){test[index]=wallet[index];}
  254. ++_countWallets;
  255. wallet=new WalletZozInc[_countWallets];
  256. for(int index{0};index<_countWallets-1;++index){wallet[index]=test[index];}
  257. wallet[_countWallets-1].changeNameOfOwnerOfWallet(FNLN, "AdminKey");};
  258.  
  259. void createDebitCard(std::string FNLN){DebitCardZozInc* test=new DebitCardZozInc[_countDebitCards];
  260. for(int index{0};index<_countDebitCards;++index){test[index]=debitCard[index];}
  261. ++_countDebitCards;
  262. debitCard=new DebitCardZozInc[_countDebitCards];
  263. for(int index{0};index<_countDebitCards-1;++index){debitCard[index]=test[index];}
  264. debitCard[_countDebitCards-1].changeNameOfOwnerOfDebitCard(FNLN, "AdminKey");};
  265. void createDebitCard(char* FNLN){DebitCardZozInc* test=new DebitCardZozInc[_countDebitCards];
  266. for(int index{0};index<_countDebitCards;++index){test[index]=debitCard[index];}
  267. ++_countDebitCards;
  268. debitCard=new DebitCardZozInc[_countDebitCards];
  269. for(int index{0};index<_countDebitCards-1;++index){debitCard[index]=test[index];}
  270. debitCard[_countDebitCards-1].changeNameOfOwnerOfDebitCard(FNLN, "AdminKey");};
  271.  
  272. void createCreditCard(std::string FNLN){
  273. bool check=false;
  274. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getCreditLimit()!=0){check=true;}}
  275. if(check==false){
  276. CreditCardZozInc* test=new CreditCardZozInc[_countCreditCards];
  277. for(int index{0};index<_countCreditCards;++index){test[index]=creditCard[index];}
  278. ++_countCreditCards;
  279. creditCard=new CreditCardZozInc[_countCreditCards];
  280. for(int index{0};index<_countCreditCards-1;++index){creditCard[index]=test[index];}
  281. creditCard[_countCreditCards-1].changeNameOfOwnerOfCreditCard(FNLN, "AdminKey");}};
  282. void createCreditCard(char* FNLN){
  283. bool check=false;
  284. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getCreditLimit()!=0){check=true;}}
  285. if(check==false){
  286. CreditCardZozInc* test=new CreditCardZozInc[_countCreditCards];
  287. for(int index{0};index<_countCreditCards;++index){test[index]=creditCard[index];}
  288. ++_countCreditCards;
  289. creditCard=new CreditCardZozInc[_countCreditCards];
  290. for(int index{0};index<_countCreditCards-1;++index){creditCard[index]=test[index];}
  291. creditCard[_countCreditCards-1].changeNameOfOwnerOfCreditCard(FNLN, "AdminKey");}};
  292.  
  293. //Operation with money
  294. void putMoneyWallet(int idWallet,long double money){
  295. for(int index{0};index<_countWallets;++index){if(wallet[index].getId()==idWallet){wallet[index].addMoney(money);break;}}
  296.  
  297. }
  298. void minucMoneyWallet(int idWallet,long double money){
  299. for(int index{0};index<_countWallets;++index){if(wallet[index].getId()==idWallet){wallet[index].minucMoney(money);break;}}}
  300.  
  301. void putMoneyDebitCard(int idDebitCard,long double money){
  302. for(int index{0};index<_countDebitCards;++index){if(debitCard[index].getId()==idDebitCard){debitCard[index].addMoney(money);break;}}}
  303. void minucMoneyDebitCard(int idDebitCard,long double money){
  304. for(int index{0};index<_countDebitCards;++index){if(debitCard[index].getId()==idDebitCard){debitCard[index].minucMoney(money);break;}}
  305. }
  306.  
  307. void putMoneyCreditCard(int idCreditCard,long double money){
  308. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getId()==idCreditCard){creditCard[index].addMoney(money);break;}}
  309. }
  310. void minucMoneyCreditCard(int idCreditCard,long double money){
  311. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getId()==idCreditCard){creditCard[index].minucMoney(money);break;}}
  312. }
  313.  
  314. void getCredit(int idCreditCard,long double money){
  315. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getId()==idCreditCard){creditCard[index].receiveCreditMoney(money);break;}}
  316. }
  317.  
  318. //Names
  319. void changeNameOfWallet(int idWallet,std::string name){
  320. for(int index{0};index<_countWallets;++index){if(wallet[index].getId()==idWallet){wallet[index].changeNameOfWallet(name);break;}}
  321. }
  322. void changeNameOfWallet(int idWallet,char* name){
  323. for(int index{0};index<_countWallets;++index){if(wallet[index].getId()==idWallet){wallet[index].changeNameOfWallet(name);break;}}
  324. }
  325.  
  326. void changeNameOfDebitCard(int idDebitCard,std::string name){
  327. for(int index{0};index<_countDebitCards;++index){if(debitCard[index].getId()==idDebitCard){debitCard[index].changeNameOfDebitCard(name);break;}}
  328. }
  329. void changeNameOfDebitCard(int idDebitCard,char* name){
  330. for(int index{0};index<_countDebitCards;++index){if(debitCard[index].getId()==idDebitCard){debitCard[index].changeNameOfDebitCard(name);break;}}
  331. }
  332.  
  333. void changeNameOfCreditCard(int idCreditCard,std::string name){
  334. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getId()==idCreditCard){creditCard[index].changeNameOfCreditCard(name);break;}}
  335. }
  336. void changeNameOfCreditCard(int idCreditCard,char* name){
  337. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getId()==idCreditCard){creditCard[index].changeNameOfCreditCard(name);break;}}
  338. }
  339.  
  340. //Stats
  341. void showStatWallet(int idWallet){
  342. for(int index{0};index<_countWallets;++index){if(wallet[index].getId()==idWallet){wallet[index].showMyWallet();break;}}}
  343.  
  344. void showStatDebitCard(int idDebitCard){
  345. for(int index{0};index<_countDebitCards;++index){if(debitCard[index].getId()==idDebitCard){debitCard[index].showMyDebitCard();break;}}
  346. }
  347.  
  348. void showStatCreditCard(int idCreditCard){
  349. for(int index{0};index<_countCreditCards;++index){if(creditCard[index].getId()==idCreditCard){creditCard[index].showMyCreditCard();break;}}
  350. }
  351.  
  352. //Methods finance system
  353. std::string getFNLN(){return _FNLN;}
  354.  
  355. //Files
  356. void makeCopy()
  357. {
  358. std::ofstream file;
  359. file.open("reserve.txt");
  360. file<<getFNLN()<<"\n";
  361. file<<_passwordToFinanceSystem<<"\n";
  362. file<<idsWallets<<"\n";
  363. file<<idsDebitCards<<"\n";
  364. file<<idsCreditCards<<"\n";
  365. file<<_countWallets<<"\n";
  366. file<<_countDebitCards<<"\n";
  367. file<<_countCreditCards<<"\n";
  368. for(int index{0};index<_countWallets;++index)
  369. {
  370. file<<wallet[index].getId()<<"\n";
  371. file<<wallet[index].getNameOfOwnerOfWallet()<<"\n";
  372. file<<wallet[index].getNameOfWallet()<<"\n";
  373. file<<wallet[index].getMoney()<<"\n";
  374. }
  375. for(int index{0};index<_countDebitCards;++index)
  376. {
  377. file<<debitCard[index].getId()<<"\n";
  378. file<<debitCard[index].getNameOfOwnerOfDebitCard()<<"\n";
  379. file<<debitCard[index].getNameOfDebitCard()<<"\n";
  380. file<<debitCard[index].getMoney()<<"\n";
  381. }
  382. for(int index{0};index<_countCreditCards;++index)
  383. {
  384. file<<creditCard[index].getId()<<"\n";
  385. file<<creditCard[index].getNameOfOwnerOfCreditCard()<<"\n";
  386. file<<creditCard[index].getNameOfCreditCard()<<"\n";
  387. file<<creditCard[index].getMoney()<<"\n";
  388. file<<creditCard[index].getCreditLimit()<<"\n";
  389. }
  390. file.close();
  391. }
  392. void returnFile(std::ifstream& file)
  393. {
  394. std::string line;
  395. std::getline(file,line);
  396. _FNLN=line;
  397. std::getline(file,line);
  398. _passwordToFinanceSystem=line;
  399. std::getline(file,line);
  400. idsWallets=stoi(line);
  401. std::getline(file,line);
  402. idsDebitCards=stoi(line);
  403. std::getline(file,line);
  404. idsCreditCards=stoi(line);
  405. std::getline(file,line);
  406. _countWallets=stoi(line);
  407. std::getline(file,line);
  408. _countDebitCards=stoi(line);
  409. std::getline(file,line);
  410. _countCreditCards=stoi(line);
  411. for(int index{0};index<_countWallets;++index)
  412. {
  413. std::getline(file,line);
  414. wallet[index].changeId(stoi(line), "AdminKey");
  415. std::getline(file,line);
  416. wallet[index].changeNameOfOwnerOfWallet(line, "AdminKey");
  417. std::getline(file,line);
  418. wallet[index].changeNameOfWallet(line);
  419. std::getline(file,line);
  420. wallet[index].changeMoney(stoi(line), "AdminKey");
  421. }
  422. for(int index{0};index<_countDebitCards;++index)
  423. {
  424. std::getline(file,line);
  425. debitCard[index].changeId(stoi(line), "AdminKey");
  426. std::getline(file,line);
  427. debitCard[index].changeNameOfOwnerOfDebitCard(line, "AdminKey");
  428. std::getline(file,line);
  429. debitCard[index].changeNameOfDebitCard(line);
  430. std::getline(file,line);
  431. debitCard[index].changeMoney(stoi(line), "AdminKey");
  432. }
  433. for(int index{0};index<_countCreditCards;++index)
  434. {
  435. std::getline(file,line);
  436. creditCard[index].changeId(stoi(line), "AdminKey");
  437. std::getline(file,line);
  438. creditCard[index].changeNameOfOwnerOfCreditCard(line, "AdminKey");
  439. std::getline(file,line);
  440. creditCard[index].changeNameOfCreditCard(line);
  441. std::getline(file,line);
  442. creditCard[index].changeMoney(stoi(line), "AdminKey");
  443. std::getline(file,line);
  444. creditCard[index].changeCreditLimit(stoi(line), "AdminKey");
  445. }
  446.  
  447. }
  448. };
  449.  
  450. int menuFinance()
  451. {
  452. int num;
  453. std::cout<<"\t\tSelect\n";
  454. std::cout<<"1) Wallet\n";
  455. std::cout<<"2) Debit Card\n";
  456. std::cout<<"3) Credit Card\n";
  457. std::cin>>num;
  458. return num;
  459. }
  460. int menuOperation()
  461. {
  462. int num;
  463. std::cout<<"\t\tOperation Menu\n";
  464. std::cout<<"1) Put money\n";
  465. std::cout<<"2) Get money\n";
  466. std::cout<<"3) Get credit\n";
  467. std::cout<<"4) ShowStat\n";
  468. std::cin>>num;
  469. return num;
  470. }
  471. int menuMain()
  472. {
  473. int num;
  474. std::cout<<"\t\tMain menu\n";
  475. std::cout<<"1) Create wallet\n";
  476. std::cout<<"2) Create debit card\n";
  477. std::cout<<"3) Create credit card\n";
  478. std::cout<<"4) Operation with money\n";
  479. std::cout<<"5) Make reserve copy\n";
  480. std::cout<<"6) Exit\n";
  481. std::cin>>num;
  482. return num;
  483. }
  484.  
  485. int main()
  486. {
  487. int choice;
  488. std::cout<<"Want to download copy from file reserve.txt? 1 - Yes\nChoice = ";
  489. std::cin>>choice;
  490. FinanceSystemZozInc financeSystem("Andrey Zozulych","1234");
  491. if(choice==1){
  492. std::ifstream file("reserve.txt");
  493. financeSystem.returnFile(file);
  494. file.close();
  495.  
  496. }
  497. while(true)
  498. {
  499. int select = menuMain();
  500. if(select==1){ financeSystem.createWallet(financeSystem.getFNLN()); }
  501. else if(select==2){financeSystem.createDebitCard(financeSystem.getFNLN());}
  502. else if(select==3){financeSystem.createCreditCard(financeSystem.getFNLN());}
  503. else if(select==4){
  504. int selectSecond = menuOperation();
  505. if(selectSecond==1){
  506. int selectSystem=menuFinance();
  507. if(selectSystem==1)
  508. {
  509. int id,money;
  510. std::cout<<"ID Wallet = ";
  511. std::cin>>id;
  512. std::cout<<"Money = ";
  513. std::cin>>money;
  514. financeSystem.putMoneyWallet(id, money);
  515. }
  516. else if(selectSystem==2)
  517. {
  518. int id,money;
  519. std::cout<<"ID Debit Card = ";
  520. std::cin>>id;
  521. std::cout<<"Money = ";
  522. std::cin>>money;
  523. financeSystem.putMoneyDebitCard(id, money);
  524. }
  525. else if(selectSystem==3)
  526. {
  527. int id,money;
  528. std::cout<<"ID Credit Card = ";
  529. std::cin>>id;
  530. std::cout<<"Money = ";
  531. std::cin>>money;
  532. financeSystem.putMoneyCreditCard(id, money);
  533. }
  534. }
  535. else if(selectSecond==2){
  536. int selectSystem=menuFinance();
  537. if(selectSystem==1)
  538. {
  539. int id,money;
  540. std::cout<<"ID Wallet = ";
  541. std::cin>>id;
  542. std::cout<<"Money = ";
  543. std::cin>>money;
  544. financeSystem.minucMoneyWallet(id, money);
  545. }
  546. else if(selectSystem==2)
  547. {
  548. int id,money;
  549. std::cout<<"ID Debit Card = ";
  550. std::cin>>id;
  551. std::cout<<"Money = ";
  552. std::cin>>money;
  553. financeSystem.minucMoneyDebitCard(id, money);
  554. }
  555. else if(selectSystem==3)
  556. {
  557. int id,money;
  558. std::cout<<"ID Credit Card = ";
  559. std::cin>>id;
  560. std::cout<<"Money = ";
  561. std::cin>>money;
  562. financeSystem.minucMoneyCreditCard(id, money);
  563. }
  564. }
  565. else if(selectSecond==3){
  566. int id,creditLimit;
  567. std::cout<<"ID Credit Card = ";
  568. std::cin>>id;
  569. std::cout<<"Credit = ";
  570. std::cin>>creditLimit;
  571. financeSystem.getCredit(id, creditLimit);
  572. }
  573. else if(selectSecond==4){
  574. int selectSystem=menuFinance();
  575. if(selectSystem==1)
  576. {
  577. int id;
  578. std::cout<<"ID Wallet = ";
  579. std::cin>>id;
  580. financeSystem.showStatWallet(id);
  581. }
  582. else if(selectSystem==2)
  583. {
  584. int id;
  585. std::cout<<"ID Debit Card = ";
  586. std::cin>>id;
  587. financeSystem.showStatDebitCard(id);
  588. }
  589. else if(selectSystem==3)
  590. {
  591. int id;
  592. std::cout<<"ID Credit Card = ";
  593. std::cin>>id;
  594. financeSystem.showStatCreditCard(id);
  595. }
  596. }
  597.  
  598. }
  599. else if(select==5){financeSystem.makeCopy();}
  600. else if(select==6){break;}
  601. }
  602. }
  603.  
  604. int FinanceSystemZozInc::idsWallets=0;
  605. int FinanceSystemZozInc::idsDebitCards=0;
  606. int FinanceSystemZozInc::idsCreditCards=0;
  607.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement