From bcfeae501bae6090b186fce829cd3725e335c532 Mon Sep 17 00:00:00 2001 From: "maissane.elmjidi" Date: Fri, 27 Sep 2024 10:51:47 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20projet=20music&coV2=20maissane=20modifi?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Test.java | 74 +++++++++++++++++++++++++++++++++---- src/métiers/Entreprise.java | 17 +++++++++ 2 files changed, 84 insertions(+), 7 deletions(-) diff --git a/src/Test.java b/src/Test.java index c47b1e2..90d2372 100644 --- a/src/Test.java +++ b/src/Test.java @@ -1,4 +1,5 @@ +import java.util.Scanner; import métiers.Commande; import métiers.Entreprise; import métiers.Instrument; @@ -12,27 +13,86 @@ import métiers.Instrument; * * @author Maissane */ -public class Test { + + public class Test { /** * @param args the command line arguments */ public static void main(String[] args) { + + + //condition pour une premiere commande et si il y en a d'autre + boolean choix = false; + System.out.println("Voulez vous passer une commande ? oui = true /non = false "); + Scanner v = new Scanner(System.in); + boolean choixutili = v.nextBoolean(); + while(choixutili) + { + Entreprise lEntreprise=new Entreprise("MusicAndCo"); - Commande laCommande1 = new Commande(1,1,"12/09/2024"); - Commande laCommande2 = new Commande(2,1,"12/09/2024"); + Commande laCommande1 = new Commande(1,1,"26/09/2024"); + int i = 0; //ajouter des instruments de l'entreprise à la commande + System.out.println("\t--- BIENVENUE CHEZ MUSIC&CO --- "); + System.out.println("\tVoici la liste des instruments en vente : "); + // ArrayList lesInstruments = new ArrayList<>(); + for(Instrument instruments : lEntreprise.getLesInstruments() ){ + i = i+1; + System.out.println(i); + System.out.println("\t\n" + instruments + "\t\n"); + } + System.out.println("--- Quel(s) instrument(s) souhaitez vous acheter ? Saisisez le numero du menu ---"); + Scanner sc = new Scanner(System.in); + int index = sc.nextInt(); + System.out.println("Vous avez saisi : " + index); + System.out.println(" indiquer la quantitée souhaitée: "); + int qte = sc.nextInt() ;//innitialiser la variable qte a 0 + // String.valueOf(qte); //convertir la variable int en String + // str = sc.nextLine(); //saisie de la saisie clavier de l'utilisateur + + // System.out.println(index) ; + + System.out.println( lEntreprise.getLesInstruments().get(index-1)) ; //affiche le produit choisi + laCommande1.ajouter(lEntreprise.getLesInstruments().get(index-1), qte); //ajout de l'instrument à la commande + // System.out.println("Voici votre panier : " + laCommande1.toString()); //afficher la commande + // System.out.println("Voici votre panier : " + lEntreprise. ); //afficher la commande + System.out.println("Instrument choisi = " + lEntreprise.getLesInstruments().get(index-1).getDesignation()); //affichage de la designation de l'instrument choisi + System.out.println("Quantité choisi = " + qte); //affichage de la qté choisi de l'utilisateur + System.out.println("Date de votre commande: " + laCommande1.getDateCom()); //affichage de la date de la commande + System.out.println("Nombre de panier : " + laCommande1.getNoCom()); //affichage du numero de la commande + // laCommande1.ajouter(index, qte); //methode pour ajouter la commande pas fini + + System.out.println("Souhaitez vous rajouter des articles dans votre commande ? "); //demander à l'utilisateur si il veut rajouter des articles + v = new Scanner(System.in); + choixutili = v.nextBoolean(); + } + + + + + + //affecter la commande à l'entreprise si la comamnde est possible - lEntreprise.ajouterCommande(laCommande1); + // lEntreprise.ajouterCommande(laCommande1); //créer une autre commande - + Commande laCommande2 = new Commande(2,2,"26/09/2024"); //rechercher et afficher une commande - + // System.out.println( laCommande1.toString()); + // System.out.println( laCommande2.toString()); //supprimer une des 2 commande - } + + //laCommande2 = null; + + + + + + } } + diff --git a/src/métiers/Entreprise.java b/src/métiers/Entreprise.java index 235f9d5..47b5d8c 100644 --- a/src/métiers/Entreprise.java +++ b/src/métiers/Entreprise.java @@ -63,4 +63,21 @@ public class Entreprise { } return uneCommande; } + + public ArrayList getLesCommandes() { + return lesCommandes; + } + + public void setLesCommandes(ArrayList lesCommandes) { + this.lesCommandes = lesCommandes; + } + + public ArrayList getLesInstruments() { + return lesInstruments; + } + + public void setLesInstruments(ArrayList lesInstruments) { + this.lesInstruments = lesInstruments; + } + }