Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- AUTEUR: Laura Elisa Salas
- DESCRIPTION: Logiciel de operations en finance.
- ***********************************************************************/
- /* ------------------------- */
- /* LES #include DU PROGRAMME */
- /* ------------------------- */
- #include <iostream>
- #include <iomanip>
- #include <conio.h>
- #include <string>
- #include <windows.h>
- #include <time.h> // utile pour les types "time_t" et "tm", et pour les fonctions "time(...)" et "localtime_s(...)"
- #include "../console(v1.9).h"
- using namespace std;
- /* ------------------------------------ */
- /* LES CONSTANTES GLOBALES DU PROGRAMME */
- /* ------------------------------------ */
- const double MARGE_CREDIT_MAX = 10000; // marge de crédit maximun d'un compte du client, attibuée lors de la création du client [0..10000]
- const double SOLDE_COMPTE_MAX = 1000000; // maximun à ne pas dépasser dans un compte d'un client
- // Nombre maximal de clients.
- const int NB_CLIENTS_MAX = 70;
- // Nombre de comptes par client.
- const int NB_COMPTES_PAR_CLIENT_MAX = 3;
- /* -------------------------------------- */
- /* LES STRUCTURES DE DONNÉES DU PROGRAMME */
- /* -------------------------------------- */
- enum Commandes {
- ajouter,
- depot,
- retrait,
- virement,
- afficherInfo,
- listerClients,
- supprimer,
- quitter
- };
- // Représente le nom complet d'un client
- struct Nom
- {
- string prenom;
- string nom;
- };
- // Représente une adresse postale
- struct Adresse
- {
- string noCivique;
- string rue;
- string ville;
- string codePostal;
- };
- // Contient les informations personnelles d'un client
- struct InfoPersonnel
- {
- Nom nom;
- Adresse adresse;
- string telephone;
- string nas;
- };
- // Informations d'un seul compte de banque
- struct Compte
- {
- double solde;
- double margeCredit;
- };
- // Contient toutes les informations relatives à un client (informations personnelles, comptes, date d'inscription)
- struct Client /// this puts together all the info from the client, including his 3 accounts and since when has he been a client
- {
- InfoPersonnel info;
- Compte compte[NB_COMPTES_PAR_CLIENT_MAX];
- time_t clientDepuis;
- };
- // La base de données des clients
- struct BaseDeDonnées
- {
- int nombreDeClients;
- Client clients[NB_CLIENTS_MAX];
- };
- /* ----------------------------------- */
- /* LES VARIABLES GLOBALES DU PROGRAMME */
- /* ----------------------------------- */
- // Les variables globales ne sont pas permises
- /* ---------------------------- */
- /* LES PROTOTYPES DES FONCTIONS */
- /* ---------------------------- */
- void IU_FlushTampons();
- double arrondir(double v, int p);
- void IU_Bip();
- void IU_Bip_DialogueErreur(string message);
- // OBLIGATOIRE : Écrire les prototypes de toutes vos fonctions ici ...
- /* ----------------------------------------- */
- /* LES FONCTIONS TRÈS GÉNÉRALES DU PROGRAMME */
- /* ----------------------------------------- */
- void IU_FlushTampons() // pour vider les 2 tampons
- {
- if (cin.fail()) cin.clear(); // s'assure que le cin est remis en marche
- cin.ignore(cin.rdbuf()->in_avail()); // vide le tampon du cin
- while (_kbhit()) _getch(); // vide l'autre tampon
- }
- double arrondir(double v, int p = 2) // input v et précision p
- {
- double e = pow(10, p);
- return round(v * e) / e;
- }
- // FONCTIONS GÉNÉRALES POUR LE SIGNALEMENT D'ERREURS (exemples)
- void IU_Bip() { cout << "\a"; }
- void IU_Bip_DialogueErreur(string message)
- {
- IU_Bip();
- MessageBoxA( NULL, message.c_str(), "ERREUR", MB_OK|MB_ICONSTOP|MB_SYSTEMMODAL );
- }
- /* Écrire vos fonctions générales ici ... */
- /// unsure about this
- //int verificationChiffreValide(int chiffre, int coordonnee_x, int coordonnee_y)
- //{
- // do
- // {
- // gotoxy(coordonnee_x, coordonnee_y);
- // cin >> chiffre;
- // } while (cin.fail());
- // return chiffre;
- //}
- //string dateAString(time_t date) //conversion de seconde en date; fonction tiree de stackoverflow et modifiee un peu.
- //{
- // string date_en_lettres;
- // tm *ltm = localtime(&date);
- //
- // // print various components of tm structure.
- // date_en_lettres = to_string(ltm->tm_mday) + "/" + to_string(1 + ltm->tm_mon) + "/" + to_string(1900 + ltm->tm_year);
- //
- // return date_en_lettres;
- //}
- string dateAString(time_t date)
- {
- string date_en_lettres;
- tm ltm;
- localtime_s(<m, &date);
- date_en_lettres = to_string(ltm.tm_mday) + "/" + to_string(1 + ltm.tm_mon) + "/" + to_string(1900 + ltm.tm_year);
- return date_en_lettres;
- }
- /* ----------------------------------------------------------------------- */
- /* FONCTIONS GÉNÉRALES POUR L'INTERFACE USAGER (IU) EN LECTURE OU ÉCRITURE */
- /* ----------------------------------------------------------------------- */
- void IU_AfficherMenuPrincipal()
- {
- gotoxy(16, 0); cout << "Compagnie 420-B21";
- gotoxy(16, 4); cout << "1. Ajouter un client";
- gotoxy(16, 6); cout << "2. Dépôt";
- gotoxy(16, 8); cout << "3. Retrait";
- gotoxy(16, 10); cout << "4. Virement";
- gotoxy(16, 12); cout << "5. Afficher les informations d'un client";
- gotoxy(16, 14); cout << "6. Lister les clients et leur crédit actuel";
- gotoxy(16, 16); cout << "7. Supprimer un client";
- gotoxy(16, 18); cout << "8. Quitter";
- gotoxy(16, 24); cout << "Entrez votre choix: ";
- }
- Commandes IU_LireUnChoixValideDuMenuPrincipal()
- {
- Commandes cmd = quitter; // Commande par défaut
- COORD choixCoord = { wherex(),wherey() };
- bool choixValide = false;
- int choix;
- char lettre_choix;
- do
- {
- clreol();
- IU_FlushTampons();
- gotoxy(choixCoord.X, choixCoord.Y);
- choix = _getch();
- if (isdigit(choix))
- {
- choix = choix - '0';
- choixValide = true;
- cout << choix;
- }
- else {
- lettre_choix = choix;
- cout << lettre_choix;
- }
- } while (choix < 1 || choix > 8 || !choixValide); //lecture et validation du choix
- switch (choix)
- {
- case 1:
- cmd = ajouter;
- break;
- case 2:
- cmd = depot;
- break;
- case 3:
- cmd = retrait;
- break;
- case 4:
- cmd = virement;
- break;
- case 5:
- cmd = afficherInfo;
- break;
- case 6:
- cmd = listerClients;
- break;
- case 7:
- cmd = supprimer;
- break;
- case 8:
- cmd = quitter;
- }
- return cmd;
- }
- void IU_MessageDeFinDuProgramme()
- {
- // Écrire le code ici ...
- }
- // Suggestion de fonctions, sous la forme de prototypes, pour décomposer votre programme en plus petits traitements réutilisables
- int IU_LireUnNoDeClient(int max);
- int IU_LireUnNoDeCompteValide();
- double IU_LireUnMontantValide(double max);
- void IU_AfficherLesInformationsDuClient(Client client);
- Client UI_LireLesInfosNouveauClient();
- /* ---------------------------------------------------------------- */
- /* LES FONCTIONS OBLIGATOIRES POUR CHAQUE TRANSACTION DU PROGRAMME */
- /* ---------------------------------------------------------------- */
- // TRANSACTION : CREATION D'UN NOUVEAU CLIENT
- void Transact_AjouterUnNouveauClient(BaseDeDonnées base)
- {
- IU_FlushTampons();
- clrscr();
- int affichage_x;
- base.nombreDeClients++;
- string date;
- char c;
- base.clients[base.nombreDeClients - 1].clientDepuis = time(0);
- date = dateAString(base.clients[base.nombreDeClients - 1].clientDepuis);
- //example of struct -> client_no.info.nom.prenom = "ste-catherine";
- gotoxy(0, 0); cout << "Transaction: ajouter un nouveau client";
- gotoxy(0, 2); cout << "Création du client #" << base.nombreDeClients;
- gotoxy(0, 4); cout << left << setw(21) << "Prénom" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.nom.prenom;
- gotoxy(0, 5); cout << left << setw(21) << "Nom" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.nom.nom;
- gotoxy(0, 7); cout << left << setw(21) << "Numéro civique" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.adresse.noCivique;
- gotoxy(0, 8); cout << left << setw(21) << "Rue" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.adresse.rue;
- gotoxy(0, 9); cout << left << setw(21) << "Ville" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.adresse.ville;
- gotoxy(0, 10); cout << left << setw(21) << "Code postal" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.adresse.codePostal;
- gotoxy(0, 11); cout << left << setw(21) << "Téléphone" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.telephone;
- gotoxy(0, 13); cout << left << setw(21) << "Numéro d'assurance sociale" << ": ";
- cin >> base.clients[base.nombreDeClients - 1].info.nas;
- gotoxy(0, 15); cout << "Marge de crédit du compte #1 (Max de " << fixed << setprecision(2) << MARGE_CREDIT_MAX << " $)" << ": "; affichage_x = wherex();
- cin >> base.clients[base.nombreDeClients - 1].compte[1].margeCredit;
- gotoxy(affichage_x, 15); cout << base.clients[base.nombreDeClients - 1].compte[1].margeCredit;
- gotoxy(0, 16); cout << "Marge de crédit du compte #2 (Max de " << fixed << setprecision(2) << MARGE_CREDIT_MAX << " $)" << ": "; affichage_x = wherex();
- cin >> base.clients[base.nombreDeClients - 1].compte[2].margeCredit;
- gotoxy(affichage_x, 16); cout << base.clients[base.nombreDeClients - 1].compte[2].margeCredit;
- gotoxy(0, 17); cout << "Marge de crédit du compte #3 (Max de " << fixed << setprecision(2) << MARGE_CREDIT_MAX << " $)" << ": "; affichage_x = wherex();
- cin >> base.clients[base.nombreDeClients - 1].compte[3].margeCredit;
- gotoxy(affichage_x, 17); cout << base.clients[base.nombreDeClients - 1].compte[3].margeCredit;
- gotoxy(0, 19); cout << "Date de création de ce dossier: " << date;
- gotoxy(0, 22); cout << "Appuyez sur une touche pour continuer";
- c = _getch();
- }
- // TRANSACTION : FAIRE UN DÉPÔT
- void Transact_FaireUnDepot( /* Paramètres ? */ )
- {
- // Écrire le code ici ...
- }
- // TRANSACTION : FAIRE UN RETAIT
- void Transact_FaireUnRetrait( /* Paramètres ? */ )
- {
- // Écrire le code ici ...
- }
- // TRANSACTION : FAIRE UN VIREMENT
- void Transact_FaireUnVirement( /* Paramètres ? */ )
- {
- // Écrire le code ici ...
- }
- // TRANSACTION : AFFICHER LES INFOS
- void Transact_AfficherTouteslesInfosDuClient( /* Paramètres ? */ )
- {
- // Écrire le code ici ...
- }
- // TRANSACTION : AFFICHER LE RAPPORT
- void Transact_ListerLesClientsEtLeurCréditActuel( /* Paramètres ? */ )
- {
- // Écrire le code ici ...
- }
- // TRANSACTION : SUPPRIMER UN CLIENT
- void Transact_SupprimerUnClient( /* Paramètres ? */ )
- {
- // Écrire le code ici ...
- }
- /* ---------------------- */
- /* LA FONCTION PRINCIPALE */
- /* ---------------------- */
- void main()
- {
- // À FAIRE: dans la fenêtre de la console : boutton de droite, propriété, font = LUCIDA CONSOLE
- // Permet d'écrire enfin vos string avec les accents !!!
- SetConsoleCP(1252);
- SetConsoleOutputCP(1252);
- BaseDeDonnées BD; // Utiliser cette définition de variable et elle DOIT RESTER ICI, c'est-à-dire local à main()
- BD.nombreDeClients = 0; // représente le nombre actuel de clients dans la base de données BD.
- Commandes cmd;
- do
- {
- IU_AfficherMenuPrincipal();
- cmd = IU_LireUnChoixValideDuMenuPrincipal();
- switch (cmd)
- {
- case ajouter: Transact_AjouterUnNouveauClient(BD); break;
- case depot: Transact_FaireUnDepot(); break;
- case retrait: Transact_FaireUnRetrait(); break;
- case virement: Transact_FaireUnVirement(); break;
- case afficherInfo: Transact_AfficherTouteslesInfosDuClient(); break;
- case listerClients: Transact_ListerLesClientsEtLeurCréditActuel(); break;
- case supprimer: Transact_SupprimerUnClient(); break;
- case quitter: IU_MessageDeFinDuProgramme(); break;
- }
- } while(cmd != quitter );
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement