Affichage des adhérents opérationnel

main
DahmaneYanis 3 years ago
parent c65be45aaa
commit 7bff18d827

Binary file not shown.

@ -1,4 +1,9 @@
#include "global.h" #include "global.h"
void help(int page);
void SupprimerAdherent(int *nbAdherent, int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[]);
void AfficheAdherents(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int tailleLog);
void ligne(void);
int SupprimerAdherent(int *nbAdherent, int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[]);

@ -7,4 +7,5 @@
#ifdef _WIN32 #ifdef _WIN32
#define clean system("cls"); #define clean system("cls");
#define color system("color 70");
#endif #endif

@ -1,5 +1,19 @@
#include "../header/adherent.h" #include "../header/adherent.h"
/**
* @brief Affiche le message d'aide demandé
*
* @param page Numéro de message d'aide demandé
*/
void help(int page){
if (page == 1)
{
printf("\nPour naviguer a travers la liste des adherents tapez :\n");
printf("\t- \"0\" pour quitter.\n\t- Sur \"-\", puis le nombre de page que vous souhaitez passer en arriere\n\t Exemple \"-1\" permet de revenir a la page precedente\n\t- Le nombre de page que vous souhaitez passer en avant\n\t Exemple \"1\" permet d'aller a la page suivante\n\t- N'importe quoi d'autre afin d'afficher ce message d'aide\n");
}
}
/** /**
* @brief Supprime un adherent * @brief Supprime un adherent
* *
@ -7,9 +21,8 @@
* @param tabNoCarte [TABLEAU] Liste des numéros de cartes des adhérents * @param tabNoCarte [TABLEAU] Liste des numéros de cartes des adhérents
* @param tabEtatCarte [TABLEAU] Liste des états des cartes des adhérents * @param tabEtatCarte [TABLEAU] Liste des états des cartes des adhérents
* @param tabPointCarte [TABLEAU] Liste des points sur les cartes des adhérents * @param tabPointCarte [TABLEAU] Liste des points sur les cartes des adhérents
* @return int Code erreur : 0 -> Tout s'est bien passé | 1 -> Adhérent pas trouvé
*/ */
int SupprimerAdherent(int *nbAdherent, int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[]) void SupprimerAdherent(int *nbAdherent, int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[])
{ {
int cible, boucle = 0; int cible, boucle = 0;
char rep; char rep;
@ -60,7 +73,7 @@ int SupprimerAdherent(int *nbAdherent, int tabNoCarte[], int tabEtatCarte[], int
if (rep == 'O') if (rep == 'O')
{ {
// AfficheAdherents(); --> APPEL DE L'AFFICHAGE DES ADHERENTS AfficheAdherents(tabNoCarte, tabEtatCarte, tabPointCarte, *nbAdherent);
} }
} }
@ -123,3 +136,92 @@ int SupprimerAdherent(int *nbAdherent, int tabNoCarte[], int tabEtatCarte[], int
} }
} }
} }
/**
* @brief Affiche tout les adhérents
*
* @param tabNoCarte [TABLEAU] Liste des cartes des adhérents
* @param tabEtatCarte [TABLEAU] Liste des états des cartes des adhérents
* @param tabPointCarte [TABLEAU] Liste des points des adhérents
* @param tailleLog Nombre d'adhérents
*/
void AfficheAdherents(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int tailleLog)
{
int commande, actif = 1;
int nbPages = tailleLog/10 + 1, noPage = 1;
char trash;
//Détermine les adhérents à afficher au début
int min = 0, max;
if (tailleLog>= 10)
max = 9;
else
max = tailleLog;
// Boucle d'affichage
while (actif)
{
clean
printf("LISTE DES ADHERENTS\n");
printf("\n\t| Numero adherent | Etat Carte | CREDIT DE LA CARTE |\n");
for (int i = min; i < max; i++)
{
ligne();
printf("\t| %15d | %10d | %18d |\n", tabNoCarte[i], tabEtatCarte[i], tabPointCarte[i]);
}
printf("\n\t\t\t PAGE %d/%d", noPage, nbPages); // Affichage du numéro de page
printf("\nCommande : ");
scanf("%d", &commande);
// Traitement de la commande
if (commande == 0)
{
actif = 0;
}
else
{
if (noPage+commande > nbPages || noPage+commande < 1)
{
help(1);
printf("\nAppuyer sur entree pour continuer...");
scanf("%*c%c", &trash);
}
else
{
noPage+=commande;
}
}
//Détermine la page (et son contenu) à afficher
min = (noPage-1)*10;
if (noPage*10 > tailleLog)
max = tailleLog;
else
max = noPage*10;
}
}
/**
* @brief Fonction qui ne sert qu'à AfficheAdherents et qui permet d'éviter la répétition de ligne
*
*/
void ligne(void)
{
printf("\t|");
for (int i = 0; i < 51; i++)
{
if(i == 17 || i == 30)
printf("|");
else
printf("-");
}
printf("|\n");
}

@ -1,14 +1,17 @@
#include "../header/adherent.h" #include "../header/adherent.h"
int main(void){ int main(void){
int tabCarte[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int tabEtat[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1};
int tabPoint[10] = {0};
int taillePhysique = 10; color
int tailleLog = 9;
int err = SupprimerAdherent(&tailleLog, tabCarte, tabEtat, tabPoint); int tabCarte[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int tabEtat[15] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
int tabPoint[15] = {0};
int taillePhysique = 15;
int tailleLog = 15;
//SupprimerAdherent(&tailleLog, tabCarte, tabEtat, tabPoint);
AfficheAdherents(tabCarte, tabEtat, tabPoint, tailleLog);
printf("\nCode erreur : %d\n", err);
} }
Loading…
Cancel
Save