Merge pull request 'client' (#1) from client into master

Reviewed-on: #1
pull/2/head
Matheo HERSAN 2 years ago
commit 420d02c8b3

1
.gitignore vendored

@ -85,6 +85,7 @@ dkms.conf
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff # User-specific stuff
.idea/
.idea/**/workspace.xml .idea/**/workspace.xml
.idea/**/tasks.xml .idea/**/tasks.xml
.idea/**/usage.statistics.xml .idea/**/usage.statistics.xml

@ -38,3 +38,4 @@ Cette commande nettoie, construit et exécute l'application.
- Si vous ne spécifiez aucune option lors de l'exécution du script, il affichera un message d'erreur vous indiquant d'utiliser --help pour afficher l'aide : - Si vous ne spécifiez aucune option lors de l'exécution du script, il affichera un message d'erreur vous indiquant d'utiliser --help pour afficher l'aide :
```bash ```bash
./build.sh --help ./build.sh --help

BIN
app

Binary file not shown.

@ -27,7 +27,7 @@ function show_command {
tput sgr0 tput sgr0
} }
# Function to display arrows with a jumping effect # Display arrows
function show_arrows_jump { function show_arrows_jump {
for _ in {1}; do for _ in {1}; do
echo -e "\n\t⬇ ⬇ ⬇ \n" echo -e "\n\t⬇ ⬇ ⬇ \n"
@ -40,7 +40,7 @@ if [ ! -d "$BUILD_DIR" ] && [ "$#" -gt 0 ] && [ "$1" != "--help" ]; then
mkdir "$BUILD_DIR" || show_error "Unable to create directory $BUILD_DIR." mkdir "$BUILD_DIR" || show_error "Unable to create directory $BUILD_DIR."
fi fi
# Clean generated files # Clean
function clean { function clean {
local command="rm -r $BUILD_DIR $APP_NAME" local command="rm -r $BUILD_DIR $APP_NAME"
echo -e "➔ Cleaning..." echo -e "➔ Cleaning..."
@ -58,7 +58,7 @@ function build {
show_success "Compilation completed." show_success "Compilation completed."
} }
# Execute the executable # Execute
function execute { function execute {
local executable="$APP_NAME" local executable="$APP_NAME"
local command="./$executable" local command="./$executable"
@ -72,7 +72,7 @@ function execute {
fi fi
} }
# Display help # --help
function show_help { function show_help {
echo "Usage: $SCRIPT_NAME [options]" echo "Usage: $SCRIPT_NAME [options]"
echo "Options:" echo "Options:"

@ -1,4 +1,4 @@
32 0 0 32 0 0
660 30.00 0 660 30.00 0
5079 75.50 0 5079 75.50 0
8043 50.50 1 8043 50.50 1

@ -0,0 +1,24 @@
//
// Created by Mathéo Hersan on 16/10/2023.
//
#include "client.h"
void afficherDonneesClient() {
FILE *fichier = fopen("donnee/client.txt", "r");
int numeroClient;
float cagnotte;
int suspendu;
if (fichier == NULL) {
fprintf(stderr, "Erreur lors de l'ouverture du fichier");
exit(EXIT_FAILURE);
}
while (fscanf(fichier, "%d%f%d", &numeroClient, &cagnotte, &suspendu) == 3) {
printf("Client %d, Cagnotte %.2f, Suspendu: %s\n",
numeroClient, cagnotte, (suspendu == 0) ? "Non" : "Oui");
}
fclose(fichier);
}

@ -0,0 +1,13 @@
//
// Created by Mathéo Hersan on 16/10/2023.
//
#ifndef SAE_101_CLIENT_H
#define SAE_101_CLIENT_H
#include<stdio.h>
#include<stdlib.h>
void afficherDonneesClient();
#endif //SAE_101_CLIENT_H

@ -0,0 +1,48 @@
#include "interface_client.h"
#include "app/core_logic/client.h"
void affiche_client(int a){
printf("\n");
printf("+-------------+ \n");
printf("|| Bonjour ! ||\n") ;
printf("+-------------+ \n");
printf("\n");
printf("+-----------------------------------------------------------------+\n");
printf("|| Que voulez-vous faire ? \t \t \t \t \t || \n");
printf("||\t1 : Afficher le récapitulatif du panier. \t \t || \n");
printf("||\t2 : Ajouter un article du panier. \t \t \t || \n");
printf("||\t3 : Supprimer un article du panier. \t \t \t || \n");
printf("||\t4 : Modifier la quantité d'un article du panier. \t || \n");
printf("||\t5 : Réinitialiser le panier. \t \t \t \t || \n");
printf("+-----------------------------------------------------------------+\n");
}
/*
* Sert à lancer le menu et faire choisir l'utilisateur
*/
void menu(int *choix, int jour) {
affiche_client(jour);
printf("Vous choisissez: ");
scanf("%d", choix);
while (*choix < 0)
{
affiche_client(jour);
printf("Vous choisissez: ");
printf("Veuillez entrer un choix valide ! \n");
scanf("%d", choix);
}
}
void global_client(){
int choix, jour;
menu(&choix, jour);
switch (choix) {
case 1:
afficherDonneesClient();
break;
default:
printf("Veuillez entrer un choix valide ! \n");
break;
}
}

@ -0,0 +1,5 @@
#include<stdio.h>
void affiche_client(int a);
void menu(int *choix, int a);
void global_client();

@ -0,0 +1 @@
#include "interface_resp.h"

@ -1,6 +1,30 @@
#include<stdio.h> #include<stdio.h>
#include<stdlib.h> #include<stdlib.h>
#include "app/interface/interface_client.h"
#include "app/interface/interface_resp.h"
#include "app/core_logic/client.h"
int choixInterface(void) {
int choix;
printf("Choix de l'interface: \n");
printf("1. Interface 'responsable': Pour les responsables \n");
printf("2. Interface 'Client' : Pour les clients\n");
printf("Vous choisissez l'interface n°: ");
scanf("%d", &choix);
if (choix < 0 || choix > 1) {
fprintf(stderr,"Veuillez entrer un choix valide ! \n");
}
switch (choix) {
case 1: printf("Vous avez choisit l'interface responsable.\n"); break;
case 2: printf("Vous avez choisit l'interface client.\n");
}
return choix;
}
int main(){ int main(){
printf("Hello World\n"); switch (choixInterface()) {
//case 1: global_resp();
case 2: global_client();
}
return 0;
} }

Loading…
Cancel
Save