Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class compte {
- public:
- compte (string nom, double taux) : intitule(nom),solde(0.0),taux(taux){}
- string nom (){return intitule;}
- void crediter (double somme){
- solde=solde+somme;
- }
- void bouclement(){
- crediter(solde*taux);
- }
- void afficher(){
- cout <<"Compte de "<< intitule<<endl;
- cout<<"Solde : "<< solde<<endl;
- }
- private:
- string intitule;
- double solde;
- double taux;
- };
- //////////////////////////////////////////
- class client {
- public:
- client (string nom, string adresse, double taux_negocie=0.01) : nom(nom), ville(adresse)
- {
- compte temp ("courant",taux_negocie); //on met ça pour créer nouveau tableau de client
- portefeuille.push_back(temp);
- }
- void ouvrir_compte(string nom, double taux){
- portefeuille.push_back(compte(nom,taux));
- }
- void afficher (){
- cout<<" Client : "<<nom<<endl;
- cout<<" Adresse : "<<ville<<endl;
- for (auto compte : portefeuille){
- compte.afficher();
- }
- }
- void bouclement(){
- for (auto& compte : portefeuille)
- {
- compte.bouclement();
- }
- }
- void crediter (string intitule, double somme){
- for (auto& compte:portefeuille){
- if (compte.nom()==intitule) {
- compte.crediter(somme);
- return;
- }
- }
- }
- private:
- string nom;
- string ville;
- vector<compte> portefeuille;
- };
- /////////////////////////////////////////
- class banque {
- public:
- void nouveau_client(client& quidam){
- clients.push_back(&quidam);
- }
- void bouclement(){
- for (auto& client:clients){
- (*client).bouclement(); //mettre () sinon il prend pas le * en compte
- }
- }
- void afficher(){
- for (auto& client:clients){
- (*client).afficher();
- }
- }
- private:
- vector<client*>clients;
- };
- int main(){
- banque offshore;
- client Cahuzac ("Cahuzac", "Paris");
- offshore.nouveau_client(Cahuzac);
- Cahuzac.crediter("courant", 200000);
- Cahuzac.ouvrir_compte("Paradis Fiscal",10);
- Cahuzac.crediter("Paradis Fiscal",500000);
- cout << "Avant le bouclement" << endl;
- offshore.afficher();
- cout << "Apres le bouclement:" << endl;
- offshore.bouclement();
- offshore.afficher();
- return 0;
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement