From cc9e98132cb0503eafc0407dec13b5c2da1accc6 Mon Sep 17 00:00:00 2001
From: "morgann.david" <morgann.david@DESKTOP-L08P31N>
Date: Thu, 26 Sep 2024 11:56:04 +0200
Subject: [PATCH] partie faite par morgann + branche morgannV2BcYeag

---
 src/Test.java               | 27 ++++++++++++++++++++++++---
 src/métiers/Commande.java   |  7 +++++++
 src/métiers/Entreprise.java | 10 ++++++++--
 3 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/src/Test.java b/src/Test.java
index e4c5072..27090e1 100644
--- a/src/Test.java
+++ b/src/Test.java
@@ -19,20 +19,41 @@ public class Test {
      */
     public static void main(String[] args) {
         Entreprise lEntreprise=new Entreprise("MusicAndCo");
-        Commande laCommande1 = new Commande(1,1,"12/09/2024");
+        Commande laCommande1 = new Commande(1,1,"26/09/2024");
+        //Afficher les instruments disponibles
+        for(Instrument unInstrument : lEntreprise.getLesInstruments()){
+            System.out.println(unInstrument.toString());
+        }
+        System.out.println("---");
         
         //ajouter des instruments de l'entreprise à la commande
+        laCommande1.ajouter(lEntreprise.getLesInstruments().get(0), 2);
+        laCommande1.ajouter(lEntreprise.getLesInstruments().get(1), 3);
         
         //affecter la commande à l'entreprise si la comamnde est possible
         lEntreprise.ajouterCommande(laCommande1);
+        for(Instrument unInstrument : lEntreprise.getLesInstruments()){
+            System.out.println(unInstrument.toString());
+        }
+        System.out.println("---");
         
         //créer une autre commande
-        
+        Commande laCommande2 = new Commande(2,1,"26/09/2024");
+        laCommande2.ajouter(lEntreprise.getLesInstruments().get(0), 1);
+        laCommande2.ajouter(lEntreprise.getLesInstruments().get(1), 1);
+        laCommande2.ajouter(lEntreprise.getLesInstruments().get(2), 5);
+        lEntreprise.ajouterCommande(laCommande2);
+        for(Instrument unInstrument : lEntreprise.getLesInstruments()){
+            System.out.println(unInstrument.toString());
+        }
+        System.out.println("---");
         
         //rechercher et afficher une commande
         
         
-        //supprimer une des 2 commande
+        //supprimer une des 2 commandes
+        
+        
     }
     
 }
diff --git a/src/métiers/Commande.java b/src/métiers/Commande.java
index aa86c01..b6c8310 100644
--- a/src/métiers/Commande.java
+++ b/src/métiers/Commande.java
@@ -82,6 +82,13 @@ private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
         boolean suppOK;
         if (lesLignes.containsKey(unInstrument) == true){
             suppOK = true;
+            //mettre le stock à jour
+            //récupération de la quantité en stock
+            int oldQte=unInstrument.getQteStock();
+            //réaffectation dans le stock de la quantité commandée
+            int qteStock=oldQte+ this.getLesLignes().get(unInstrument);
+            unInstrument.setQteStock(qteStock);
+            //suppression ligne commande
             lesLignes.remove(unInstrument);
         } else {
             suppOK = false;
diff --git a/src/métiers/Entreprise.java b/src/métiers/Entreprise.java
index 235f9d5..156e9e2 100644
--- a/src/métiers/Entreprise.java
+++ b/src/métiers/Entreprise.java
@@ -23,9 +23,9 @@ public class Entreprise {
          Instrument instr1=new Instrument(23,"Piano droit",3, 8300f);
          Instrument instr2=new Instrument(54,"Violon Alto",5, 105f);
          Instrument instr3=new Instrument(67,"Guitare Classique",8, 575f);
-         lesInstruments.add(instr3);
-         lesInstruments.add(instr2);
          lesInstruments.add(instr1);
+         lesInstruments.add(instr2);
+         lesInstruments.add(instr3);
     }
 
     public String getRaisonSociale() {
@@ -63,4 +63,10 @@ public class Entreprise {
         }
         return uneCommande;
     }
+
+    public ArrayList<Instrument> getLesInstruments() {
+        return lesInstruments;
+    }
+    
+    
 }