Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8fa260fd23 | ||
|
9977862a27 | ||
|
85ab2c6bec | ||
|
45a93f086a | ||
|
0680043384 | ||
|
b02b4b8bcf |
@@ -7,8 +7,8 @@
|
|||||||
<!-- the Compile on Save feature is turned off for the project. -->
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
<!-- in the project's Project Properties dialog box.-->
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
<project name="MusicAndCoV3" default="default" basedir=".">
|
<project name="MusicAndCo" default="default" basedir=".">
|
||||||
<description>Builds, tests, and runs the project MusicAndCoV3.</description>
|
<description>Builds, tests, and runs the project MusicAndCo.</description>
|
||||||
<import file="nbproject/build-impl.xml"/>
|
<import file="nbproject/build-impl.xml"/>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
An example of overriding the target for project execution could look like this:
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
<target name="run" depends="MusicAndCoV3-impl.jar">
|
<target name="run" depends="MusicAndCo-impl.jar">
|
||||||
<exec dir="bin" executable="launcher.exe">
|
<exec dir="bin" executable="launcher.exe">
|
||||||
<arg file="${dist.jar}"/>
|
<arg file="${dist.jar}"/>
|
||||||
</exec>
|
</exec>
|
||||||
|
@@ -19,7 +19,7 @@ is divided into following sections:
|
|||||||
- cleanup
|
- cleanup
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<project xmlns:if="ant:if" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" xmlns:unless="ant:unless" basedir=".." default="default" name="MusicAndCoV3-impl">
|
<project xmlns:if="ant:if" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" xmlns:unless="ant:unless" basedir=".." default="default" name="MusicAndCo-impl">
|
||||||
<fail message="Please build using Ant 1.8.0 or higher.">
|
<fail message="Please build using Ant 1.8.0 or higher.">
|
||||||
<condition>
|
<condition>
|
||||||
<not>
|
<not>
|
||||||
@@ -619,7 +619,7 @@ is divided into following sections:
|
|||||||
</fileset>
|
</fileset>
|
||||||
</union>
|
</union>
|
||||||
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
|
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
|
||||||
<testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="MusicAndCoV3" testname="TestNG tests" workingDir="${work.dir}">
|
<testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="MusicAndCo" testname="TestNG tests" workingDir="${work.dir}">
|
||||||
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
|
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
|
||||||
<propertyset>
|
<propertyset>
|
||||||
<propertyref prefix="test-sys-prop."/>
|
<propertyref prefix="test-sys-prop."/>
|
||||||
@@ -716,7 +716,7 @@ is divided into following sections:
|
|||||||
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
|
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
|
||||||
<isset property="test.method"/>
|
<isset property="test.method"/>
|
||||||
</condition>
|
</condition>
|
||||||
<condition else="-suitename MusicAndCoV3 -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
|
<condition else="-suitename MusicAndCo -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
|
||||||
<matches pattern=".*\.xml" string="@{testClass}"/>
|
<matches pattern=".*\.xml" string="@{testClass}"/>
|
||||||
</condition>
|
</condition>
|
||||||
<delete dir="${build.test.results.dir}" quiet="true"/>
|
<delete dir="${build.test.results.dir}" quiet="true"/>
|
||||||
@@ -1057,7 +1057,7 @@ is divided into following sections:
|
|||||||
<delete file="${built-jar.properties}" quiet="true"/>
|
<delete file="${built-jar.properties}" quiet="true"/>
|
||||||
</target>
|
</target>
|
||||||
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
|
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
|
||||||
<echo level="warn" message="Cycle detected: MusicAndCoV3 was already built"/>
|
<echo level="warn" message="Cycle detected: MusicAndCo was already built"/>
|
||||||
</target>
|
</target>
|
||||||
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
|
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
|
||||||
<mkdir dir="${build.dir}"/>
|
<mkdir dir="${build.dir}"/>
|
||||||
@@ -1728,7 +1728,7 @@ is divided into following sections:
|
|||||||
<delete file="${built-clean.properties}" quiet="true"/>
|
<delete file="${built-clean.properties}" quiet="true"/>
|
||||||
</target>
|
</target>
|
||||||
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
|
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
|
||||||
<echo level="warn" message="Cycle detected: MusicAndCoV3 was already built"/>
|
<echo level="warn" message="Cycle detected: MusicAndCo was already built"/>
|
||||||
</target>
|
</target>
|
||||||
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
|
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
|
||||||
<mkdir dir="${build.dir}"/>
|
<mkdir dir="${build.dir}"/>
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
build.xml.data.CRC32=0e137893
|
build.xml.data.CRC32=ad09f6ef
|
||||||
build.xml.script.CRC32=e04698ea
|
build.xml.script.CRC32=fbce868f
|
||||||
build.xml.stylesheet.CRC32=f85dc8f2@1.111.0.48
|
build.xml.stylesheet.CRC32=f85dc8f2@1.109.0.48
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
nbproject/build-impl.xml.data.CRC32=0e137893
|
nbproject/build-impl.xml.data.CRC32=ad09f6ef
|
||||||
nbproject/build-impl.xml.script.CRC32=63f48240
|
nbproject/build-impl.xml.script.CRC32=4c0de17b
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.111.0.48
|
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.109.0.48
|
||||||
|
@@ -28,10 +28,10 @@ debug.test.modulepath=\
|
|||||||
dist.archive.excludes=
|
dist.archive.excludes=
|
||||||
# This directory is removed when the project is cleaned:
|
# This directory is removed when the project is cleaned:
|
||||||
dist.dir=dist
|
dist.dir=dist
|
||||||
dist.jar=${dist.dir}/MusicAndCoV3.jar
|
dist.jar=${dist.dir}/MusicAndCo.jar
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
dist.jlink.dir=${dist.dir}/jlink
|
dist.jlink.dir=${dist.dir}/jlink
|
||||||
dist.jlink.output=${dist.jlink.dir}/MusicAndCoV3
|
dist.jlink.output=${dist.jlink.dir}/MusicAndCo
|
||||||
excludes=
|
excludes=
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
@@ -49,7 +49,6 @@ javac.target=21
|
|||||||
javac.test.classpath=\
|
javac.test.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}:\
|
${build.classes.dir}:\
|
||||||
${libs.testng.classpath}:\
|
|
||||||
${libs.junit_5.classpath}:\
|
${libs.junit_5.classpath}:\
|
||||||
${libs.junit_4.classpath}:\
|
${libs.junit_4.classpath}:\
|
||||||
${libs.hamcrest.classpath}
|
${libs.hamcrest.classpath}
|
||||||
@@ -74,7 +73,7 @@ jlink.additionalmodules=
|
|||||||
# The jlink additional command line parameters
|
# The jlink additional command line parameters
|
||||||
jlink.additionalparam=
|
jlink.additionalparam=
|
||||||
jlink.launcher=true
|
jlink.launcher=true
|
||||||
jlink.launcher.name=MusicAndCoV3
|
jlink.launcher.name=MusicAndCo
|
||||||
main.class=Test
|
main.class=Test
|
||||||
manifest.file=manifest.mf
|
manifest.file=manifest.mf
|
||||||
meta.inf.dir=${src.dir}/META-INF
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<type>org.netbeans.modules.java.j2seproject</type>
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
<configuration>
|
<configuration>
|
||||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
<name>MusicAndCoV3</name>
|
<name>MusicAndCo</name>
|
||||||
<source-roots>
|
<source-roots>
|
||||||
<root id="src.dir"/>
|
<root id="src.dir"/>
|
||||||
</source-roots>
|
</source-roots>
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import métiers.Commande;
|
|
||||||
import métiers.Entreprise;
|
|
||||||
import métiers.Instrument;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*VERSION SANS PLUSIEURS MENU
|
|
||||||
* @author ilona.cardot
|
|
||||||
*/
|
|
||||||
public class NewClass {
|
|
||||||
/**
|
|
||||||
* @param args the command line arguments
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Entreprise lEntreprise=new Entreprise("MusicAndCo");
|
|
||||||
Commande laCommande = new Commande(1,1,"12/09/2024");
|
|
||||||
ArrayList<Instrument> lesInstrumentsEnt = lEntreprise.getLesInstruments();
|
|
||||||
Scanner clavier = new Scanner(System.in);
|
|
||||||
String choixUtil0="";
|
|
||||||
lEntreprise.ajouterCommande(laCommande);
|
|
||||||
while(!choixUtil0.equals("N")){
|
|
||||||
System.out.println("Commande numero : "+laCommande.getNoCom()+("\t\t Date : "+laCommande.getDateCom()));
|
|
||||||
System.out.println("----------------------------------------------------------------");
|
|
||||||
System.out.println("Instruments disponible : ");
|
|
||||||
for (int i = 0; i < lesInstrumentsEnt.size(); i ++) {
|
|
||||||
System.out.println("Instrument "+(i+1)+" : "+lesInstrumentsEnt.get(i));//on ajoute 1 à l'index pour ne pas afficher instrument 0
|
|
||||||
}
|
|
||||||
System.out.println("Quel instrument souhaitez vous ajouter? (entrez son numero)");
|
|
||||||
int instrAjoutSaisie = clavier.nextInt()-1; //on supprime 1 pour avoir le bon index
|
|
||||||
System.out.println("Combien souhaitez vous en ajouter?");
|
|
||||||
int instrQteAjout = clavier.nextInt();
|
|
||||||
if (laCommande.ajouter(lesInstrumentsEnt.get(instrAjoutSaisie), instrQteAjout)==true){
|
|
||||||
System.out.println("Instrument ajoute avec succes");
|
|
||||||
laCommande.ajouter(lesInstrumentsEnt.get(instrAjoutSaisie), instrQteAjout);
|
|
||||||
} else {
|
|
||||||
System.out.println("Ajout impossible, instrument non existant ou quantite choisie superieur à la quantite disponible");
|
|
||||||
}
|
|
||||||
System.out.println("----------------------------------------------------------------");
|
|
||||||
System.out.println("Souhaitez vous ajouter des instruments à la commande? (O/N)");
|
|
||||||
choixUtil0 = clavier.next();
|
|
||||||
}
|
|
||||||
//finalisation de la commande
|
|
||||||
System.out.println("---------------------------Contenu de la commande numero "+laCommande.getNoCom()+"------------------------------");
|
|
||||||
System.out.println(laCommande.getLesLignes());
|
|
||||||
System.out.println("Validez vous la commande?(O/N)");
|
|
||||||
String choixUtil2 = clavier.next();
|
|
||||||
if (choixUtil0.equals("O")){
|
|
||||||
System.out.println("Commande validée");
|
|
||||||
lEntreprise.ajouterCommande(laCommande);
|
|
||||||
}else {
|
|
||||||
System.out.println("Commande annulée");
|
|
||||||
}
|
|
||||||
System.out.println("----------------------------------------------------------------");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import métiers.Commande;
|
||||||
import métiers.*;
|
import métiers.Entreprise;
|
||||||
import java.util.Scanner;
|
import métiers.Instrument;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
@@ -13,77 +13,22 @@ import java.util.Scanner;
|
|||||||
* @author sio
|
* @author sio
|
||||||
*/
|
*/
|
||||||
public class Test {
|
public class Test {
|
||||||
Entreprise lEntreprise=new Entreprise("MusicAndCo");
|
|
||||||
Commande laCommande = new Commande(1,1,"12/09/2024");
|
|
||||||
ArrayList<Instrument> lesInstrumentsEnt = lEntreprise.getLesInstruments();
|
|
||||||
Scanner clavier = new Scanner(System.in);
|
|
||||||
/**
|
|
||||||
* Création d'une nouvelle commande et ajout si validée
|
|
||||||
*/
|
|
||||||
public Test(){
|
|
||||||
}
|
|
||||||
public void nouvelleCommande(){
|
|
||||||
String choixUtil0="";
|
|
||||||
lEntreprise.ajouterCommande(laCommande);
|
|
||||||
while(!choixUtil0.equals("N")){
|
|
||||||
System.out.println("Commande numero : "+laCommande.getNoCom()+("\t\t Date : "+laCommande.getDateCom()));
|
|
||||||
System.out.println("----------------------------------------------------------------");
|
|
||||||
System.out.println("Instruments disponible : ");
|
|
||||||
for (int i = 0; i < lesInstrumentsEnt.size(); i ++) {
|
|
||||||
System.out.println("Instrument "+(i+1)+" : "+lesInstrumentsEnt.get(i));//on ajoute 1 à l'index pour ne pas afficher instrument 0
|
|
||||||
}
|
|
||||||
System.out.println("Quel instrument souhaitez vous ajouter? (entrez son numero)");
|
|
||||||
int instrAjoutSaisie = clavier.nextInt()-1; //on supprime 1 pour avoir le bon index
|
|
||||||
System.out.println("Combien souhaitez vous en ajouter?");
|
|
||||||
int instrQteAjout = clavier.nextInt();
|
|
||||||
if (laCommande.ajouter(lesInstrumentsEnt.get(instrAjoutSaisie), instrQteAjout)==true){
|
|
||||||
System.out.println("Instrument ajoute avec succes");
|
|
||||||
laCommande.ajouter(lesInstrumentsEnt.get(instrAjoutSaisie), instrQteAjout);
|
|
||||||
} else {
|
|
||||||
System.out.println("Ajout impossible, instrument non existant ou quantite choisie superieur à la quantite disponible");
|
|
||||||
}
|
|
||||||
System.out.println("----------------------------------------------------------------");
|
|
||||||
System.out.println("Souhaitez vous ajouter des instruments à la commande? (O/N)");
|
|
||||||
choixUtil0 = clavier.next();
|
|
||||||
}
|
|
||||||
//finalisation de la commande
|
|
||||||
System.out.println("---------------------------Contenu de la commande numero "+laCommande.getNoCom()+"------------------------------");
|
|
||||||
System.out.println(laCommande.getLesLignes());
|
|
||||||
System.out.println("Validez vous la commande?(O/N)");
|
|
||||||
String choixUtil2 = clavier.next();
|
|
||||||
if (choixUtil0.equals("O")){
|
|
||||||
System.out.println("Commande validée");
|
|
||||||
lEntreprise.ajouterCommande(laCommande);
|
|
||||||
}else {
|
|
||||||
System.out.println("Commande annulée");
|
|
||||||
}
|
|
||||||
System.out.println("----------------------------------------------------------------");
|
|
||||||
|
|
||||||
}
|
|
||||||
public void commandesExistantes(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Test test1;
|
Entreprise lEntreprise=new Entreprise("MusicAndCo");
|
||||||
test1 = new Test();
|
Instrument instr1=new Instrument(1,"Piano",10, 8300f);
|
||||||
int choixUtil=0;
|
Instrument instr2=new Instrument(2,"Violon",9, 105f);
|
||||||
while(choixUtil!=3){
|
Instrument instr3=new Instrument(3,"Guitare",8, 575f);
|
||||||
System.out.println("Que souhaitez vous faire?\n\t1 : Créer une nouvelle commande \n\t 2: Annuler une commande existante\n\t 3: Fermer l'application");
|
Commande laCommande = new Commande(1,1,"12/09/2024");
|
||||||
switch(choixUtil){
|
lEntreprise.ajouterCommande(laCommande);
|
||||||
case 1 :
|
|
||||||
test1.nouvelleCommande();
|
//Test Cas0-Ajouter à la commande une ligne de 2 instr1
|
||||||
break;
|
System.out.println("Résultat de l'ajout de 2 instr1 à la commande :" + laCommande.ajouter(instr1, 2) );
|
||||||
/*case 2 :
|
System.out.println("Nouveau stock de instr1 : "+instr1.getQteStock());
|
||||||
test1.commandesExistantes;
|
System.out.println("Quantité de la ligne de commande de instr1 :"+laCommande.getLesLignes().get(instr1));
|
||||||
break;*/
|
|
||||||
case 3 :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -36,18 +36,40 @@ private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
|||||||
* @return true si l'ajout est bon
|
* @return true si l'ajout est bon
|
||||||
*/
|
*/
|
||||||
public boolean ajouter(Instrument unInstrument, int qte){
|
public boolean ajouter(Instrument unInstrument, int qte){
|
||||||
//il faut gérer l'ajout d'un instrument existant dans la commande, ce sera une mise à jour de la ligne
|
|
||||||
//il faut empêcher l'ajout d'une ligne avec une quantité à 0
|
//il faut empêcher l'ajout d'une ligne avec une quantité à 0
|
||||||
//bien s'assurer que le stock est suffisant
|
//bien s'assurer que le stock est suffisant
|
||||||
boolean ajoutOK;
|
boolean ajoutOK=false;
|
||||||
|
//ajout d'un instrument existant dans la commande, ce sera une mise à jour de la ligne
|
||||||
|
if (lesLignes.containsKey(unInstrument))//l'instrument existe
|
||||||
|
{
|
||||||
|
//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);
|
||||||
|
//nouvel ajout
|
||||||
|
this.ajouter(unInstrument,qte);
|
||||||
|
|
||||||
|
}
|
||||||
|
else //nouvel instrument
|
||||||
|
{
|
||||||
|
//on s'assure qu'il y a assez de stock pour la commande
|
||||||
|
|
||||||
int qteDisponible = unInstrument.getQteStock();
|
int qteDisponible = unInstrument.getQteStock();
|
||||||
if (qteDisponible<qte){
|
if (qteDisponible<qte){
|
||||||
ajoutOK = false;
|
ajoutOK = false;
|
||||||
}else {
|
}else {
|
||||||
ajoutOK = true;
|
ajoutOK = true;
|
||||||
lesLignes.put(unInstrument,qte);
|
lesLignes.put(unInstrument,qte);
|
||||||
|
//màj qté stock pour déduire la qté commandée
|
||||||
unInstrument.setQteStock(qteDisponible-qte);
|
unInstrument.setQteStock(qteDisponible-qte);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ajoutOK;
|
return ajoutOK;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -57,14 +79,12 @@ private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
|||||||
*/
|
*/
|
||||||
public boolean supprimer(Instrument unInstrument){
|
public boolean supprimer(Instrument unInstrument){
|
||||||
//lesLignes.remove(unInstrument);
|
//lesLignes.remove(unInstrument);
|
||||||
|
boolean suppOK;
|
||||||
boolean suppOK = false;
|
|
||||||
if (lesLignes.containsKey(unInstrument) == true){
|
if (lesLignes.containsKey(unInstrument) == true){
|
||||||
suppOK = true;
|
suppOK = true;
|
||||||
int qteCommande = lesLignes.get(unInstrument);
|
|
||||||
lesLignes.remove(unInstrument);
|
lesLignes.remove(unInstrument);
|
||||||
int qteDisponible = unInstrument.getQteStock();
|
} else {
|
||||||
unInstrument.setQteStock(qteDisponible+qteCommande);
|
suppOK = false;
|
||||||
}
|
}
|
||||||
return suppOK;
|
return suppOK;
|
||||||
}
|
}
|
||||||
@@ -121,10 +141,5 @@ private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
|||||||
return Objects.equals(this.dateCom, other.dateCom);
|
return Objects.equals(this.dateCom, other.dateCom);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "numero de commande : " + noCom + "\t \t date de la commadne : " + dateCom + "\n contenu de la commande : " + lesLignes + '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -5,8 +5,6 @@
|
|||||||
package métiers;
|
package métiers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import métiers.Commande;
|
|
||||||
import métiers.Instrument;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -19,13 +17,6 @@ public class Entreprise {
|
|||||||
|
|
||||||
public Entreprise(String raisonSociale) {
|
public Entreprise(String raisonSociale) {
|
||||||
this.raisonSociale = raisonSociale;
|
this.raisonSociale = raisonSociale;
|
||||||
|
|
||||||
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(instr1);
|
|
||||||
lesInstruments.add(instr2);
|
|
||||||
lesInstruments.add(instr3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRaisonSociale() {
|
public String getRaisonSociale() {
|
||||||
@@ -47,9 +38,6 @@ public class Entreprise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void supprimerCommande(Commande uneCommande){
|
public void supprimerCommande(Commande uneCommande){
|
||||||
//parcours pour supprimer les instruments de la commande
|
|
||||||
|
|
||||||
//suppression de la commande
|
|
||||||
lesCommandes.remove(uneCommande);
|
lesCommandes.remove(uneCommande);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,23 +51,4 @@ public class Entreprise {
|
|||||||
}
|
}
|
||||||
return uneCommande;
|
return uneCommande;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Commande> getLesCommandes() {
|
|
||||||
return lesCommandes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Instrument> getLesInstruments() {
|
|
||||||
return lesInstruments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLesCommandes(ArrayList<Commande> lesCommandes) {
|
|
||||||
this.lesCommandes = lesCommandes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLesInstruments(ArrayList<Instrument> lesInstruments) {
|
|
||||||
this.lesInstruments = lesInstruments;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ public class Instrument {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "reference : " + ref + "\t designation : " + designation + "\t quantite en stock : " + qteStock + "\t prix : " + prix + '}';
|
return "Instrument{" + "ref=" + ref + ", designation=" + designation + ", qteStock=" + qteStock + ", prix=" + prix + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRef(int ref) {
|
public void setRef(int ref) {
|
||||||
|
@@ -29,8 +29,10 @@ public class CommandeTest {
|
|||||||
public void testAjouter() {
|
public void testAjouter() {
|
||||||
Instrument instr1=new Instrument(1,"Piano",10, 8300f);
|
Instrument instr1=new Instrument(1,"Piano",10, 8300f);
|
||||||
Instrument instr2=new Instrument(2,"Violon",9, 105f);
|
Instrument instr2=new Instrument(2,"Violon",9, 105f);
|
||||||
|
Instrument instr3=new Instrument(3,"piano",8, 105f);
|
||||||
Commande laCommande = new Commande(1,1,"12/09/2024");
|
Commande laCommande = new Commande(1,1,"12/09/2024");
|
||||||
System.out.println("ajouter");
|
System.out.println("ajouter");
|
||||||
|
//cas 0
|
||||||
boolean ajoutRes= laCommande.ajouter(instr1, 2);
|
boolean ajoutRes= laCommande.ajouter(instr1, 2);
|
||||||
boolean ajoutAttendu = true;
|
boolean ajoutAttendu = true;
|
||||||
System.out.println("cas0 : cas normal, ajout une ligne de commande");
|
System.out.println("cas0 : cas normal, ajout une ligne de commande");
|
||||||
@@ -42,50 +44,69 @@ public class CommandeTest {
|
|||||||
int qteAttendu=2;
|
int qteAttendu=2;
|
||||||
assertEquals("Test0 quantite",qteRes, qteAttendu);
|
assertEquals("Test0 quantite",qteRes, qteAttendu);
|
||||||
|
|
||||||
|
//cas 1
|
||||||
System.out.println("Cas1 : ajout autre ligne de commande");
|
System.out.println("Cas1 : ajout autre ligne de commande");
|
||||||
laCommande.ajouter(instr2, 6);
|
laCommande.ajouter(instr2, 6);
|
||||||
int tailleR=laCommande.getLesLignes().size();
|
int tailleR=laCommande.getLesLignes().size();
|
||||||
int tailleAttendue=2;
|
int tailleAttendue=2;
|
||||||
assertEquals("Test1 taille",tailleAttendue,tailleR);
|
assertEquals("Test1 taille",tailleAttendue,tailleR);
|
||||||
|
|
||||||
/* System.out.println("Cas2 : màj quantité commandée d'une ligne existante");
|
//Cas2
|
||||||
|
System.out.println("Cas2 : màj quantité commandée d'une ligne existante");
|
||||||
laCommande.ajouter(instr2, 5);
|
laCommande.ajouter(instr2, 5);
|
||||||
stockRes=instr2.getQteStock();
|
stockRes=instr2.getQteStock();
|
||||||
stockAttendu=4;
|
stockAttendu=4;
|
||||||
assertEquals("test2 stock",stockAttendu,stockRes );
|
assertEquals("test2 stock",stockAttendu,stockRes );
|
||||||
|
|
||||||
/*qteRes=laCommande.getLesLignes().get(instr2);
|
qteRes=laCommande.getLesLignes().get(instr2);
|
||||||
qteAttendu=5;
|
qteAttendu=5;
|
||||||
assertEquals("Test2 quantite", qteAttendu,qteRes);
|
assertEquals("Test2 quantite", qteAttendu,qteRes);
|
||||||
|
|
||||||
|
/*INES*/
|
||||||
System.out.println("Cas3 : ajout nouvelle ligne avec quantité > stock");
|
System.out.println("Cas3 : ajout nouvelle ligne avec quantité > stock");
|
||||||
|
|
||||||
|
boolean test= laCommande.ajouter(instr3, 12);
|
||||||
|
stockRes=instr3.getQteStock();
|
||||||
|
stockAttendu=8;
|
||||||
|
boolean testResultExpected=false;
|
||||||
|
|
||||||
|
assertEquals("test3 stock",stockAttendu,stockRes );
|
||||||
|
assertEquals("La méthode ajouter retourne false",testResultExpected,test );
|
||||||
|
|
||||||
|
System.out.println("Nombre de ligne dans le dictionnaire: "+laCommande.getLesLignes().size());
|
||||||
|
System.out.println("Résultat de la méthode ajouter: " + test);
|
||||||
|
|
||||||
|
/*MAISSANE*/
|
||||||
System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0");
|
System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0");
|
||||||
|
/*MORGANN*/
|
||||||
System.out.println("Cas5 : mise à 0 quantité commandée d'une ligne existante");
|
System.out.println("Cas5 : mise à 0 quantité commandée d'une ligne existante");
|
||||||
|
/*ILONA*/
|
||||||
|
System.out.println("Cas6 : màj d'une ligne existante avec qté>stock");
|
||||||
|
|
||||||
System.out.println("Cas6 : màj d'une ligne existante avec qté>stock");*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSupprimer() {
|
public void testSupprimer() {
|
||||||
|
//instanciation
|
||||||
|
|
||||||
Instrument instr1=new Instrument(1,"Piano",10, 8300f);
|
Instrument instr1=new Instrument(1,"Piano",10, 8300f);
|
||||||
Instrument instr2=new Instrument(2,"Violon",9, 105f);
|
Instrument instr2=new Instrument(2,"Violon",9, 105f);
|
||||||
Commande laCommande2 = new Commande(1,1,"12/09/2024");
|
Commande laCommande = new Commande(1,1,"12/09/2024");
|
||||||
laCommande2.ajouter(instr1,2);
|
laCommande.ajouter(instr1, 2);
|
||||||
boolean expectedResult=false;
|
boolean expectedResult=false;
|
||||||
boolean expectedResult2=true;
|
boolean expectedResult2=true;
|
||||||
int stockAttendu=10;
|
|
||||||
System.out.println("Test de la méthode supprimer");
|
|
||||||
boolean test = laCommande2.supprimer(instr2);
|
|
||||||
boolean test2 = laCommande2.supprimer(instr1);
|
|
||||||
int test3 = instr1.getQteStock();
|
|
||||||
assertEquals("suppression impossible : ",expectedResult,test);
|
|
||||||
assertEquals("suppression possible : ",expectedResult2,test2);
|
|
||||||
assertEquals("Quantité d'instr1 en stock",stockAttendu,test3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// test
|
||||||
|
|
||||||
|
boolean test= laCommande.supprimer(instr2);
|
||||||
|
boolean test2= laCommande.supprimer(instr1);
|
||||||
|
|
||||||
|
assertEquals("suppression impossible",expectedResult,test);
|
||||||
|
assertEquals("suppression possible ",test2,expectedResult2 );
|
||||||
|
|
||||||
|
System.out.println("Nombre de ligne dans le dictionnaire: "+laCommande.getLesLignes().size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
<?xml version='1.0' encoding='UTF-8' ?>
|
|
||||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
|
||||||
<suite name="MusicAndCo">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
see examples at http://testng.org/doc/documentation-main.html#testng-xml
|
|
||||||
|
|
||||||
<suite-files>
|
|
||||||
<suite-file path="./junit-suite.xml" />
|
|
||||||
</suite-files>
|
|
||||||
|
|
||||||
<test name="TimeOut">
|
|
||||||
<classes>
|
|
||||||
<class name="test.timeout.TimeOutTest" />
|
|
||||||
<class name="test.timeout.TimeOutFromXmlTest"/>
|
|
||||||
<class name="test.timeout.TimeOutThreadLocalSampleTest"/>
|
|
||||||
</classes>
|
|
||||||
</test>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<test name="métiers suite">
|
|
||||||
<packages>
|
|
||||||
<package name="métiers"/>
|
|
||||||
</packages>
|
|
||||||
</test>
|
|
||||||
|
|
||||||
</suite>
|
|
Reference in New Issue
Block a user