Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. class compte {
  8. public:
  9.  
  10. compte (string nom, double taux) : intitule(nom),solde(0.0),taux(taux){}
  11.  
  12. string nom (){return intitule;}
  13.  
  14. void crediter (double somme){
  15. solde=solde+somme;
  16. }
  17.  
  18. void bouclement(){
  19.  
  20. crediter(solde*taux);
  21.  
  22. }
  23.  
  24. void afficher(){
  25.  
  26. cout <<"Compte de "<< intitule<<endl;
  27. cout<<"Solde : "<< solde<<endl;
  28.  
  29.  
  30. }
  31.  
  32.  
  33. private:
  34. string intitule;
  35. double solde;
  36. double taux;
  37.  
  38.  
  39. };
  40.  
  41. //////////////////////////////////////////
  42.  
  43. class client {
  44. public:
  45. client (string nom, string adresse, double taux_negocie=0.01) : nom(nom), ville(adresse)
  46. {
  47. compte temp ("courant",taux_negocie); //on met ça pour créer nouveau tableau de client
  48. portefeuille.push_back(temp);
  49. }
  50.  
  51.  
  52.  
  53. void ouvrir_compte(string nom, double taux){
  54. portefeuille.push_back(compte(nom,taux));
  55.  
  56. }
  57. void afficher (){
  58.  
  59. cout<<" Client : "<<nom<<endl;
  60. cout<<" Adresse : "<<ville<<endl;
  61.  
  62. for (auto compte : portefeuille){
  63.  
  64. compte.afficher();
  65.  
  66. }
  67. }
  68.  
  69. void bouclement(){
  70. for (auto& compte : portefeuille)
  71. {
  72. compte.bouclement();
  73. }
  74.  
  75.  
  76.  
  77. }
  78.  
  79. void crediter (string intitule, double somme){
  80.  
  81. for (auto& compte:portefeuille){
  82.  
  83. if (compte.nom()==intitule) {
  84.  
  85. compte.crediter(somme);
  86. return;
  87.  
  88.  
  89. }
  90. }
  91.  
  92. }
  93.  
  94.  
  95.  
  96. private:
  97. string nom;
  98. string ville;
  99. vector<compte> portefeuille;
  100.  
  101. };
  102.  
  103. /////////////////////////////////////////
  104.  
  105. class banque {
  106. public:
  107. void nouveau_client(client& quidam){
  108.  
  109. clients.push_back(&quidam);
  110.  
  111.  
  112. }
  113. void bouclement(){
  114. for (auto& client:clients){
  115.  
  116. (*client).bouclement(); //mettre () sinon il prend pas le * en compte
  117. }
  118.  
  119. }
  120. void afficher(){
  121.  
  122. for (auto& client:clients){
  123.  
  124.  
  125. (*client).afficher();
  126.  
  127. }
  128.  
  129.  
  130. }
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. private:
  138. vector<client*>clients;
  139.  
  140.  
  141. };
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150. int main(){
  151.  
  152. banque offshore;
  153.  
  154. client Cahuzac ("Cahuzac", "Paris");
  155. offshore.nouveau_client(Cahuzac);
  156. Cahuzac.crediter("courant", 200000);
  157. Cahuzac.ouvrir_compte("Paradis Fiscal",10);
  158. Cahuzac.crediter("Paradis Fiscal",500000);
  159.  
  160.  
  161.  
  162.  
  163. cout << "Avant le bouclement" << endl;
  164. offshore.afficher();
  165. cout << "Apres le bouclement:" << endl;
  166. offshore.bouclement();
  167.  
  168. offshore.afficher();
  169. return 0;
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement