Académique Documents
Professionnel Documents
Culture Documents
I. ENONCE DU PROBLEME :
Comme nous lavons dit plutt dans notre propos liminaire, il sagit ici dcrire un
programme en langage turbo pascal qui effectue la vente puis ressort la facture dans un stock de 14
articles.
Nous avons opts pour une notation mathmatiques des oprations effectues, soient :
nom:string[30];
nombre:integer;
prix:integer;
end;
designation:string[255];
quantite:integer;
prix_unite:integer;
prix_total:integer;
end;
numero:integer;
client:string[30];
contenu:array[1..t]of part;
net_payer:integer;
vendeur:string[30];
end;
la dfinition des types prdfinis tant faite, la listes des objets de mme que leur
quintessences, que nous utiliserons dans notre programme est rsume ainsi quil suit dans le
tableau suivant:
NOM TYPE NATURE SENS UTILISATION VALEUR VALEUR
INITIALE FINALE
T integer constante Taille de la liste des intermdiaire 14 14
articles
I integer Variable Parcours de boucle intermdiaire / /
J integer Variable Parcours de boucle intermdiaire / /
K integer Variable Rcupre lindex intermdiaire / /
dun lment dans
un tableau
Option char Variable Opre un choix et entre / /
offre menu associ
L Liste_article Variable Stock des articles entre / /
disponibles
F facture Variable Facture des articles sortie / /
vendus
Nom_article String[30] Variable Rechercher un nom entre / /
darticle dans le stock
des articles
Annee Word Variable Anne du jour de sortie / /
vente
Mois Word Variable Mois du jour de Sortie / /
vente
Jour Word Variable Indice du jour de Sortie / /
vente
Joursem Word Variable Jour de vente Sortie / /
Joursem2 String[30] Variable Jour de vente Sortie / /
Heure Word Variable Heure de vente Sortie / /
Minute Word Variable Minute de vente Sortie / /
Seconde Word Variable Seconde de vente Sortie / /
Centieme word Variable Centime de vente sortie / /
a,b,c,d integer Variable Coordonne dune intermediaire / /
fentre :
(a,b)=coordonne s
du coin superieur
gauche ;(c,d)=coordo
nnes du con
inferieur droit.
c, l, c_a, n_l integer variable (c,l)=coordonne de intermdiaire / /
interval, l_a, n_c debut de ligne ou de
colonne;
C_a=colonne darrt
de ligne
n_l=nombre de
ligne ;
interval=intervalle
entre les lignes ou
des colonnes
l_a :ligne darrt
n_c=nombre de
colonne
V Array[1..t]o variable Liste des produits intermediaire / /
f part vendus
E integer variable Couleur de intermdiaire / /
remplissage de la
fentre
Compt integer variable Nombre darticle intermdiaire / /
vendu
program projet_pascal;
uses crt,dos;{----les unit crt pour la gestion de l'ecran et dos pour la gestion date et heure----}
nom:string[30];
nombre:integer;
prix:integer;
end;
designation:string[255];
quantite:integer;
prix_unite:integer;
prix_total:integer;
end;
numero:integer;
client:string[30];
contenu:array[1..t]of part;
net_payer:integer;
vendeur:string[30];
end;
var i,j,k:integer;{---i,j,k en general pour les parcours de boucle et k specialement pour localiser et
recuperer une valeur---}
option:char;{----pour operer des choix et en general pour aller d'un menu un autre}
l:liste_article;
f:facture;
annee,mois,jour,joursem,heure,minute,seconde,centieme:word;{--------------------------------------
-------------}
{---------------------------------------------------}
{--------------------------------------------------------------}
{--------------------------------------------------------------}
{--------------------------------------------------------------}
{--------------------------------------------------------------}
{------------------------------------}
{------------------------------------}
procedure interface_principale;
var i,j:integer;
begin
window(1,1,80,26);
{cadre principal}
gotoxy(1,1);
write(chr(201));
for i:=2 to 79 do
write(chr(205));
write(chr(187));
for i:=2 to 5 do
writeln(chr(186));
gotoxy(80,1);
for i:=2 to 5 do
begin
gotoxy(80,i);
writeln(chr(186));
end;
gotoxy(1,5);
write(char(204));
for i:=2 to 79 do
write(chr(205));
write(chr(185));
for i:=5 to 18 do
writeln(chr(186));
gotoxy(80,5);
for i:=6 to 19 do
begin
gotoxy(80,i);
writeln(chr(186));
end;
gotoxy(1,20);
write(chr(204));
for i:=2 to 79 do
write(chr(205));
write(chr(185));
for i:=20 to 23 do
writeln(chr(186));
gotoxy(80,20);
for i:=21 to 24 do
begin
gotoxy(80,i);
writeln(chr(186));
end;
gotoxy(1,25);
write(chr(200));
for i:=2 to 79 do
write(chr(205));
write(chr(188));
{premiere case}
window(2,2,79,4);
for i:=2 to 79 do
for j:=2 to 4 do
begin
textbackground(9);
write(' ');
end;
gotoxy(23,2);
textcolor(10);
{deuxieme case}
window(2,6,79,19);
for i:=2 to 79 do
for j:=6 to 20 do
begin
textbackground(10);
write(' ');
end;
{troisime case}
window(2,21,79,24);
for i:=2 to 79 do
for j:=21 to 25 do
begin
textbackground(11);
write(' ');
end;
end;
{------------------------------------------}
{------------------------------------------}
procedure menu_principal;
begin
window(1,26,80,57);
clrscr;
interface_principale;
window(2,6,79,19);
textbackground(4);
textcolor(15);
gotoxy(1,1);
writeln('MENU PRINCIPAL');
textbackground(11);
for i:=6 to 10 do
begin
gotoxy(25,i);
textbackground(10);
case i of
6:write('A- Afficher la liste des articles');
end;
end;
window(2,21,79,24);
gotoxy(13,3);
textbackground(11);
window(35,23,37,23);
for i:=35 to 37 do
begin
textbackground(0);
write(' ');
gotoxy(2,2);
end;
end;
{---------------------------------------}
{--------------------------------------}
procedure init_case2;
begin
window(2,6,79,19);
for i:=2 to 79 do
for j:=6 to 20 do
begin
textbackground(10);
write(' ');
end;
end;
{---------------------------------------}
{--------------------------------------}
procedure init_case3;
begin
window(2,21,79,24);
for i:=2 to 79 do
for j:=21 to 25 do
begin
textbackground(11);
write(' ');
end;
end;
{------------------------------------------------}
{------------------------------------------------}
procedure rectangulaire(a,b,c,d,e:integer);
begin
window(a,b,c,d);
for i:=a to c do
for j:=b to d do
begin
gotoxy(i,j);
textbackground(e);
write(' ');
end;
end;
{-----------------------------------------------}
{-----------------------------------------------}
procedure interface_vente(a:integer);
begin
init_case3;
init_case2;
textbackground(4);
textcolor(15);
gotoxy(1,1);
case a of
1:begin
textbackground(10);
gotoxy(4,4);
write('client:');rectangulaire(13,9,30,11,0);window(2,6,79,19);textbackground(10);
gotoxy(4,10);
write('vendeur:');rectangulaire(13,14,30,16,0);window(2,6,79,19);textbackground(10);
end;
2:begin
textbackground(10);
gotoxy(40,4);
write('Article:');rectangulaire(50,9,68,11,0);window(2,6,79,19);textbackground(10);
gotoxy(40,10);
write('nombre:');rectangulaire(50,14,68,16,0);window(2,6,79,19);
end;
end;
readln;
end;
{--------------------------------------------}
{--------------------------------------------}
function recherche(nom_article:string):boolean;
begin
for i:=1 to t do
begin
if l[i].nom=nom_article then
begin
k:=i;
recherche:=true;
break;
end
else recherche:=false;
end;
end;
{-------------------------------------------------------------------------------------}
{-------------------------------------------------------------------------------------}
procedure ligne(c,l,c_a,n_l,interval:integer);
begin
begin
gotoxy(c,l);
begin
write(char(196));
gotoxy(c+j,l);
end;
l:=l+interval;
end;
end;
{------------------------------------------------------------------------------------}
procedure colonne(c,l,l_a,n_c,interval:integer);
begin
begin
gotoxy(c,l);
begin
write(char(179));
gotoxy(c,l+j);
end;
c:=c+interval;
end;
end;
{----------------------------------------------------}
{----------------------------------------------------}
procedure actualiser_liste_article;
begin
rectangulaire(1,26,19,28,4);
gotoxy(5,2);
write('NUMERO');
rectangulaire(20,26,39,28,5);
gotoxy(5,2);
write('NOM');
rectangulaire(39,26,57,28,6);
gotoxy(4,2);
write('NOMBRE');
rectangulaire(58,26,77,28,10);
gotoxy(6,2);
write('PRIX');
textcolor(15);
textbackground(0);
window(1,29,80,140);
ligne(1,1,78,16,2);
colonne(1,1,30,6,19);
for i:=1 to t do
begin
gotoxy(9,2*i);
write(i);
gotoxy(22,2*i);
writeln(l[i].nom);
gotoxy(42,2*i);
for j:=1 to 12 do
begin
gotoxy(42+j,2*i);
write(' ');
end;
gotoxy(42,2*i);
writeln(l[i].nombre);
gotoxy(62,2*i);
writeln(l[i].prix);
end;
end;
{------------------------------------------------}
{------------------------------------------------}
function test_facture(p:facture):boolean;
begin
for i:=1 to t do
begin
if p.contenu[i].quantite<>0 then
begin
test_facture:=true;
break;
end
else
test_facture:=false;
end;
end;
{-----------------------------------------------}
{-----------------------------------------------}
procedure fiche_facture;
var compt:integer;
v: array[1..t]of part;
begin
window(1,26,80,140);
textbackground(0);
textcolor(15);
gotoxy(2,2);
writeln('I . A . I - CAMEROUN');
gotoxy(45,2);
getdate(annee,mois,jour,joursem);
case joursem of
end;
gettime(heure,minute,seconde,centieme);
write('A ',heure,'H',minute,'''',seconde,'"');
gotoxy(30,5);
gotoxy(2,8);
write('Mr(Mme): ',f.client);
compt:=0;
for i:=1 to t do
begin
if f.contenu[i].quantite>0 then
begin
compt:=compt+1;
v[compt]:=f.contenu[i];
end;
end;
ligne(1,1,80,3,((compt+2+11)*2)-11+4-2);
colonne(1,1,((compt+2+11)*2)-11+4,3,79);
ligne(1,10,78,compt+2+11,2);
colonne(1,10,((compt+2+11)*2)-11,6,19);
gotoxy(30,((compt+2+11)*2)-11+4-2);
gotoxy(2,13);
gotoxy(2,11);
write('DESIGNATION');
gotoxy(22,11);
write('QUANTITE');
gotoxy(42,11);
write('PRIX UNITE');
gotoxy(62,11);
write('PRIX TOTAL');
gotoxy(42,((compt+2+11)*2)-11-2);
write('NET A PAYER');
f.net_payer:=0;
begin
f.net_payer:=f.net_payer+v[i].prix_total;
gotoxy(4,11+2*i);
write(v[i].designation);
gotoxy(22,11+2*i);
writeln(v[i].quantite);
gotoxy(42,11+2*i);
for j:=1 to 12 do
begin
gotoxy(42+j,11+2*i);
write(' ');
end;
gotoxy(42,11+2*i);
writeln(v[i].prix_unite);
gotoxy(62,11+2*i);
writeln(v[i].prix_total);
end;
gotoxy(62,((compt+2+11)*2)-11-2);
write(f.net_payer);
rectangulaire(40,24,41,24,0);
readln;
end;
{--------------------------------------------}
{-------menu facturation---------------------}
{--------------------------------------------}
procedure facturer;
begin
textcolor(15);
init_case2;
gotoxy(1,1);
textbackground(4);
write('MENU FACTURATION');
textbackground(10);
if test_facture(f)=false then
begin
init_case3;
gotoxy(1,1);
textbackground(4);
write('OPTIONS');
textbackground(11);
gotoxy(10,1);
textcolor(4);
gotoxy(10,2);
textcolor(15);
rectangulaire(40,24,41,24,11);
end
else
begin
f.numero:=f.numero+1;
init_case3;
gotoxy(1,1);
textbackground(4);
write('OPTIONS');
textbackground(11);
gotoxy(10,2);
textcolor(4);
textcolor(15);
fiche_facture;
rectangulaire(40,24,41,24,11);
end;
end;
{---------------------------------------------------}
{---------------------------------------------------}
procedure menu_vente_article;
var nbre:integer;
begin
actualiser_liste_article;
interface_vente(1);
rectangulaire(13,9,30,11,3);
gotoxy(1,1);
readln(f.client);
rectangulaire(13,14,30,16,3);
gotoxy(1,1);
read(f.vendeur);
interface_vente(2);
repeat
repeat
textcolor(15);
rectangulaire(50,9,68,11,3);
gotoxy(1,1);
readln(nom_article);
recherche(nom_article);
init_case3;
if recherche(nom_article)=false then
begin
init_case3;
gotoxy(2,2);
textcolor(4);
rectangulaire(75,24,76,24,11);
readln;
init_case3;
end
until recherche(nom_article)=true;
repeat
rectangulaire(50,14,68,16,3);
textcolor(15);
gotoxy(1,1);
readln(nbre);
if l[k].nombre=0 then
begin
init_case3;
gotoxy(2,2);
textcolor(4);
rectangulaire(40,24,41,24,0);
readln;
break;
end
else
begin
init_case3;
gotoxy(2,2);
textcolor(4);
rectangulaire(75,24,76,24,11);
readln;
init_case3;
end;
until (nbre>0)and(nbre<=l[k].nombre);
init_case3;
gotoxy(1,1);
textcolor(15);
textbackground(4);
write('OPTIONS');
textbackground(11);
gotoxy(1,2);
writeln('a- suivant');
rectangulaire(65,23,66,23,0);
repeat
readln(option);
f.contenu[k].designation:=nom_article;
f.contenu[k].prix_unite:=l[k].prix;
f.contenu[k].prix_total:=f.contenu[k].quantite*f.contenu[k].prix_unite;
init_case3;
if l[k].nombre<>0 then
l[k].nombre:=l[k].nombre-nbre;
case option of
'a':begin
actualiser_liste_article;
rectangulaire(50,14,68,16,0);
end;
'b':begin
textbackground(0);
window(1,26,80,140);
clrscr;
facturer;
textbackground(0);
end;
end;
until option='b';
end;
{-----------------------------------------------------}
{-----------------------------------------------------}
procedure affiche_liste_article;
begin
actualiser_liste_article;
init_case2;
gotoxy(1,1);
textbackground(4);
textbackground(10);
textcolor(15);
init_case3;
gotoxy(1,1);
textbackground(4);
writeln('OPTIONS');
gotoxy(1,3);
textbackground(11);
gotoxy(8,2);
gotoxy(8,3);
gotoxy(40,3);
write('choix:');
rectangulaire(48,23,50,23,0);
repeat
read(option);
end;
{--------------------------------------------------------}
{--------------------------------------------------------}
procedure rempli_liste;
begin
l[1].nom:='imprimante';l[1].nombre:=50;l[1].prix:=150000;
l[2].nom:='souris';l[2].nombre:=30;l[2].prix:=3500;
l[3].nom:='moniteur';l[3].nombre:=75;l[3].prix:=20000;
l[4].nom:='scanner';l[4].nombre:=60;l[4].prix:=110000;
l[5].nom:='cable hdmi';l[5].nombre:=100;l[5].prix:=1500;
l[6].nom:='cable vga';l[6].nombre:=100;l[6].prix:=2000;
l[7].nom:='webcam';l[7].nombre:=200;l[7].prix:=10000;
l[8].nom:='galaxy s3';l[8].nombre:=25;l[8].prix:=250000;
l[9].nom:='i_pad';l[9].nombre:=15;l[9].prix:=3000000;
l[10].nom:='i_phone5';l[10].nombre:=22;l[10].prix:=275000;
l[11].nom:='onduleur';l[11].nombre:=45;l[11].prix:=35000;
l[13].nom:='lampe chargeable';l[13].nombre:=70;l[13].prix:=15000;
l[14].nom:='camera hd';l[14].nombre:=100;l[14].prix:=60000;
end;
{-----------------------------------------------------------------------------------------------------------------------------------
----------------}
{-----------------------------------------------------------------------------------------------------------------------------------
----------------}
{----------------------------------------------------------programme principal---------------------------------------------
-------------------------}
{-----------------------------------------------------------------------------------------------------------------------------------
----------------}
{-----------------------------------------------------------------------------------------------------------------------------------
----------------}
begin
rempli_liste;
{je fais une copie partielle de la liste des articles vers le contenu de la facture tout en initialisant la
quantit deja vendu 0}
for i:=1 to t do
begin
f.numero:=0;
f.contenu[i].designation:=l[i].nom;
f.contenu[i].quantite:=0;
f.contenu[i].prix_unite:=l[i].prix;
end;
repeat
menu_principal;
repeat
read(option);
case option of
'a':affiche_liste_article;
'b':menu_vente_article;
'c':{quitte l'application};
end;
readln;
until option='c';
end.