You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
4.2 KiB
172 lines
4.2 KiB
#include "FonctionsClient.h"
|
|
#include "FonctionsResponsable.h"
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
int ajoutPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], int n)
|
|
{
|
|
int refP,code,quantite,pos;
|
|
printf("Saisir la référence du produit à ajouter au panier: ");
|
|
scanf("%d",&refP);
|
|
|
|
pos = posRefC(TrefC,n,refP,nArticle,Tref);
|
|
if (pos != -1)
|
|
{
|
|
printf("L'article existe déja dans le panier.");
|
|
return nArticle;
|
|
}
|
|
|
|
code = posRef(Tref,refP,n);
|
|
while (code == -1)
|
|
{
|
|
printf("Erreur ; Cette référence n'existe pas dans la base de donnée; retapez : ");
|
|
scanf("%d",&refP);
|
|
code = posRef(Tref,refP,n);
|
|
}
|
|
|
|
printf("Saisir la quantité souhaité pour le produit: ");
|
|
scanf("%d",&quantite);
|
|
while (quantite < 1)
|
|
{
|
|
printf("Erreur ; La quantité peut seulement être positive; retapez : ");
|
|
scanf("%d",&quantite);
|
|
}
|
|
printf("\nRéférence : %d\n",refP);
|
|
printf("Quantité : %d\n",quantite);
|
|
TrefC[nArticle] = refP;
|
|
TquanC[nArticle] = quantite;
|
|
return nArticle +=1;
|
|
}
|
|
|
|
float initVoiture(float *chargeV)
|
|
{
|
|
float volV;
|
|
printf("Quel est le volume (L) du coffre de votre véhicule : ");
|
|
scanf("%f",&volV);
|
|
while (volV < 0)
|
|
{
|
|
printf("Erreur ; Le volume doit être positif ; retapez : ");
|
|
scanf("%f",&volV);
|
|
}
|
|
printf("Quel est la charge totale de votre véhicule (Kg) : ");
|
|
scanf("%f",chargeV);
|
|
while (*chargeV < 0)
|
|
{
|
|
printf("Erreur ; La charge doit être positive ; retapez : ");
|
|
scanf("%f",chargeV);
|
|
}
|
|
|
|
return volV;
|
|
}
|
|
|
|
|
|
void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[],float Tvolume[],float Tprix[],float chargeV, float volV,int n)
|
|
{
|
|
printf("\nRéf\tQté\tPoids\tVol\tPrixU\tPoidsTot\tVolTot\tPrixTot\tCagnotte\n");
|
|
int i, pos,cagnotte;
|
|
float prixtot,volR,chargeR;
|
|
int cfinal=0;
|
|
float prixfinal=0,volfinal=0,chargefinal=0;
|
|
for (i=0;i <nArticle;i++)
|
|
{
|
|
pos = posRef(Tref,TrefC[i],n);
|
|
prixtot=Tprix[pos]*TquanC[i];
|
|
cagnotte=prixtot*0.1;
|
|
prixfinal+=prixtot;
|
|
cfinal+=cagnotte;
|
|
volfinal+=Tvolume[pos]*TquanC[i];
|
|
chargefinal+=Tpoid[pos]*TquanC[i];
|
|
printf("%d\t%d\t%.1f\t%.1f\t%.1f\t%.1f\t\t%.1f\t%.1f\t%d\n",TrefC[i],TquanC[i],Tpoid[pos],Tvolume[pos],Tprix[pos],Tpoid[pos]*TquanC[i],Tvolume[pos]*TquanC[i],prixtot,cagnotte);
|
|
}
|
|
printf("\n\t\t\t\t\t\tPrix total à payer:\t%.0f euros\n",prixfinal);
|
|
printf("\t\t\t\t\t\tCagnotte totale:\t%d euros\n",cfinal);
|
|
|
|
volR = volV - volfinal;
|
|
printf("Volume utilisé: %.0f litres\n",volfinal);
|
|
printf("Volume restant: ");
|
|
if (volR < 0)
|
|
{
|
|
printf("Attention dépassement de la charge autorisée de ");
|
|
volR *= -1;
|
|
}
|
|
printf("%.0f litres\n",volR);
|
|
|
|
|
|
chargeR = chargeV - chargefinal;
|
|
printf("Charge Actuelle: %.0f kg\n",chargefinal);
|
|
printf("Charge restante: ");
|
|
if (chargeR < 0)
|
|
{
|
|
printf("Attention dépassement de la charge autorisée de ");
|
|
chargeR *= -1;
|
|
}
|
|
printf("%.0f kg\n",chargeR);
|
|
}
|
|
|
|
int posRefC(int TrefC[], int n, int refR,int nArticle,int Tref[])
|
|
{
|
|
int i,pos;
|
|
for (i=0;i <nArticle;i++)
|
|
{
|
|
pos = posRef(Tref,TrefC[i],n);
|
|
if (refR == TrefC[i]) return i;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int SupprArticlePanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n)
|
|
{
|
|
if (nArticle <= 0)
|
|
{
|
|
printf("Il n'y a aucun article dans le panier.");
|
|
return nArticle;
|
|
}
|
|
int refR,pos;
|
|
printf("Saisir la référence de l'article a supprimer: ");
|
|
scanf("%d",&refR);
|
|
pos = posRefC(TrefC,n,refR,nArticle,Tref);
|
|
if (pos == -1)
|
|
{
|
|
printf("L'article n'existe pas dans le panier.");
|
|
}
|
|
else
|
|
{
|
|
TrefC[pos] = TrefC[pos+1];
|
|
TquanC[pos] = TquanC[pos+1];
|
|
return nArticle - 1;
|
|
}
|
|
}
|
|
|
|
void ModifArticlePanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n)
|
|
{
|
|
if (nArticle <= 0)
|
|
{
|
|
printf("Il n'y a aucun article dans le panier.");
|
|
return;
|
|
}
|
|
int refR,pos,nQuan;
|
|
printf("Saisir la référence de l'article a modifier: ");
|
|
scanf("%d",&refR);
|
|
pos = posRefC(TrefC,n,refR,nArticle,Tref);
|
|
if (pos == -1)
|
|
{
|
|
printf("L'article n'existe pas dans le panier.");
|
|
}
|
|
else
|
|
{
|
|
printf("Saisir la nouvelle quantité du produit: ");
|
|
scanf("%d",&nQuan);
|
|
TquanC[pos] = nQuan;
|
|
}
|
|
}
|
|
|
|
int ResetPanier(int TrefC[],int TquanC[],int nArticle)
|
|
{
|
|
int i;
|
|
for (i=0;i<=nArticle;i++)
|
|
{
|
|
TrefC[i]=0;
|
|
TquanC[i]=0;
|
|
}
|
|
return 0;
|
|
} |