Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
/* ------------------------- */ /* 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(); }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
30 min ago | 11.91 KB
Christmas Gift
58 min ago | 0.84 KB
December smells like money (Release)
CSS | 58 min ago | 0.82 KB
Untitled
2 hours ago | 12.54 KB
Patch: Get available spaces
4 hours ago | 0.52 KB
Untitled
4 hours ago | 15.20 KB
GAINAX
5 hours ago | 3.57 KB
Untitled
10 hours ago | 22.81 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!