From 14d700295a6110ce7cfb5f70b478ad81000e025c Mon Sep 17 00:00:00 2001 From: "ilona.cardot" Date: Thu, 26 Sep 2024 11:55:57 +0200 Subject: [PATCH] Classe test --- build.xml | 146 +- nbproject/build-impl.xml | 3542 ++++++++++++++++---------------- nbproject/genfiles.properties | 16 +- nbproject/project.properties | 198 +- nbproject/project.xml | 30 +- src/NewClass.java | 63 + src/Test.java | 81 +- src/métiers/Commande.java | 253 +-- src/métiers/Entreprise.java | 41 +- src/métiers/Instrument.java | 2 +- test/métiers/CommandeTest.java | 45 +- 11 files changed, 2286 insertions(+), 2131 deletions(-) create mode 100644 src/NewClass.java diff --git a/build.xml b/build.xml index b576e10..4bf49c4 100644 --- a/build.xml +++ b/build.xml @@ -1,73 +1,73 @@ - - - - - - - - - - - Builds, tests, and runs the project MusicAndCo. - - - + + + + + + + + + + + Builds, tests, and runs the project MusicAndCoV3. + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index cdf0b00..68c3ad1 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1,1771 +1,1771 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index c219f37..73c7c42 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=ad09f6ef -build.xml.script.CRC32=fbce868f -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. -# 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=ad09f6ef -nbproject/build-impl.xml.script.CRC32=4c0de17b -nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.109.0.48 +build.xml.data.CRC32=0e137893 +build.xml.script.CRC32=e04698ea +build.xml.stylesheet.CRC32=f85dc8f2@1.111.0.48 +# 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. +nbproject/build-impl.xml.data.CRC32=0e137893 +nbproject/build-impl.xml.script.CRC32=63f48240 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.111.0.48 diff --git a/nbproject/project.properties b/nbproject/project.properties index f35ff40..936b1be 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,99 +1,99 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/MusicAndCo.jar -dist.javadoc.dir=${dist.dir}/javadoc -dist.jlink.dir=${dist.dir}/jlink -dist.jlink.output=${dist.jlink.dir}/MusicAndCo -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs=\ --enable-preview --enable-preview -javac.deprecation=false -javac.external.vm=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=21 -javac.target=21 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.testng.classpath}:\ - ${libs.junit_5.classpath}:\ - ${libs.junit_4.classpath}:\ - ${libs.hamcrest.classpath} -javac.test.modulepath=\ - ${javac.modulepath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.html5=false -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -# The jlink additional root modules to resolve -jlink.additionalmodules= -# The jlink additional command line parameters -jlink.additionalparam= -jlink.launcher=true -jlink.launcher.name=MusicAndCo -main.class=Test -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs=\ --enable-preview -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/MusicAndCoV3.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/MusicAndCoV3 +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs=\ --enable-preview --enable-preview +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=21 +javac.target=21 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.testng.classpath}:\ + ${libs.junit_5.classpath}:\ + ${libs.junit_4.classpath}:\ + ${libs.hamcrest.classpath} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=MusicAndCoV3 +main.class=Test +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs=\ --enable-preview +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index 1545aab..b47d9af 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -1,15 +1,15 @@ - - - org.netbeans.modules.java.j2seproject - - - MusicAndCo - - - - - - - - - + + + org.netbeans.modules.java.j2seproject + + + MusicAndCoV3 + + + + + + + + + diff --git a/src/NewClass.java b/src/NewClass.java new file mode 100644 index 0000000..95c40df --- /dev/null +++ b/src/NewClass.java @@ -0,0 +1,63 @@ + +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 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("----------------------------------------------------------------"); + + } +} \ No newline at end of file diff --git a/src/Test.java b/src/Test.java index 0bc84af..7eecf5b 100644 --- a/src/Test.java +++ b/src/Test.java @@ -1,7 +1,7 @@ -import métiers.Commande; -import métiers.Entreprise; -import métiers.Instrument; +import java.util.ArrayList; +import métiers.*; +import java.util.Scanner; /* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license @@ -13,16 +13,77 @@ import métiers.Instrument; * @author sio */ public class Test { - + Entreprise lEntreprise=new Entreprise("MusicAndCo"); + Commande laCommande = new Commande(1,1,"12/09/2024"); + ArrayList 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 */ public static void main(String[] args) { - Entreprise lEntreprise=new Entreprise("MusicAndCo"); - Commande laCommande = new Commande(1,1,"12/09/2024"); - lEntreprise.ajouterCommande(laCommande); - - //ajouter 3 piano droit et 2 violon alto dans la commande - } + Test test1; + test1 = new Test(); + int choixUtil=0; + while(choixUtil!=3){ + 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"); + switch(choixUtil){ + case 1 : + test1.nouvelleCommande(); + break; + /*case 2 : + test1.commandesExistantes; + break;*/ + case 3 : + break; + } +} + } diff --git a/src/métiers/Commande.java b/src/métiers/Commande.java index ef5631f..aead700 100644 --- a/src/métiers/Commande.java +++ b/src/métiers/Commande.java @@ -1,123 +1,130 @@ -/* - * 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 - */ - -package métiers; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * - * @author ilona - */ -public class Commande { - -private int noCom, noVendeur; -private String dateCom; - - -private final HashMap lesLignes = new HashMap<>(); - - - public Commande(int noCom, int noVendeur, String dateCom) { - this.noCom = noCom; - this.noVendeur = noVendeur; - this.dateCom = dateCom; - } - - - /** - * Ajoute une quantité donnée d'un instrument à la commande - * @param unInstrument instrument à ajouter - * @param qte quantité à ajouter - * @return true si l'ajout est bon - */ - 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 - //bien s'assurer que le stock est suffisant - boolean ajoutOK; - int qteDisponible = unInstrument.getQteStock(); - if (qteDisponible getLesLignes() { - return lesLignes; - } - - - public void setNoCom(int noCom) { - this.noCom = noCom; - } - - public void setNoVendeur(int noVendeur) { - this.noVendeur = noVendeur; - } - - public void setDateCom(String dateCom) { - this.dateCom = dateCom; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Commande other = (Commande) obj; - if (this.noCom != other.noCom) { - return false; - } - if (this.noVendeur != other.noVendeur) { - return false; - } - return Objects.equals(this.dateCom, other.dateCom); - } - - -} +/* + * 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 + */ + +package métiers; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * + * @author ilona + */ +public class Commande { + +private int noCom, noVendeur; +private String dateCom; + + +private final HashMap lesLignes = new HashMap<>(); + + + public Commande(int noCom, int noVendeur, String dateCom) { + this.noCom = noCom; + this.noVendeur = noVendeur; + this.dateCom = dateCom; + } + + + /** + * Ajoute une quantité donnée d'un instrument à la commande + * @param unInstrument instrument à ajouter + * @param qte quantité à ajouter + * @return true si l'ajout est bon + */ + 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 + //bien s'assurer que le stock est suffisant + boolean ajoutOK; + int qteDisponible = unInstrument.getQteStock(); + if (qteDisponible getLesLignes() { + return lesLignes; + } + + + public void setNoCom(int noCom) { + this.noCom = noCom; + } + + public void setNoVendeur(int noVendeur) { + this.noVendeur = noVendeur; + } + + public void setDateCom(String dateCom) { + this.dateCom = dateCom; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Commande other = (Commande) obj; + if (this.noCom != other.noCom) { + return false; + } + if (this.noVendeur != other.noVendeur) { + return false; + } + 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 + '}'; + } + + +} diff --git a/src/métiers/Entreprise.java b/src/métiers/Entreprise.java index 1802835..45cf425 100644 --- a/src/métiers/Entreprise.java +++ b/src/métiers/Entreprise.java @@ -15,17 +15,17 @@ import métiers.Instrument; public class Entreprise { private String raisonSociale; private ArrayList lesCommandes = new ArrayList<>(); - + private ArrayList lesInstruments = new ArrayList<>(); + public Entreprise(String raisonSociale) { this.raisonSociale = raisonSociale; - - ArrayList lesInstruments = new ArrayList<>(); - Instrument instr1=new Instrument(23,"Piano droit",3, 8300f); + + 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() { @@ -40,19 +40,19 @@ public class Entreprise { public String toString() { return "Entreprise{" + "raisonSociale=" + raisonSociale + '}'; } - - + + public void ajouterCommande(Commande uneCommande){ lesCommandes.add(uneCommande); } - + public void supprimerCommande(Commande uneCommande){ //parcours pour supprimer les instruments de la commande - + //suppression de la commande lesCommandes.remove(uneCommande); } - + public Commande rechercherCommande(int noCom){ Commande uneCommande = null; for(Commande laCommande : lesCommandes){ @@ -63,4 +63,23 @@ public class Entreprise { } return uneCommande; } + + public ArrayList getLesCommandes() { + return lesCommandes; + } + + public ArrayList getLesInstruments() { + return lesInstruments; + } + + public void setLesCommandes(ArrayList lesCommandes) { + this.lesCommandes = lesCommandes; + } + + public void setLesInstruments(ArrayList lesInstruments) { + this.lesInstruments = lesInstruments; + } + } + + diff --git a/src/métiers/Instrument.java b/src/métiers/Instrument.java index f38de2f..89cbecd 100644 --- a/src/métiers/Instrument.java +++ b/src/métiers/Instrument.java @@ -25,7 +25,7 @@ public class Instrument { @Override public String toString() { - return "Instrument{" + "ref=" + ref + ", designation=" + designation + ", qteStock=" + qteStock + ", prix=" + prix + '}'; + return "reference : " + ref + "\t designation : " + designation + "\t quantite en stock : " + qteStock + "\t prix : " + prix + '}'; } public void setRef(int ref) { diff --git a/test/métiers/CommandeTest.java b/test/métiers/CommandeTest.java index eb5d7fc..6bb63d0 100644 --- a/test/métiers/CommandeTest.java +++ b/test/métiers/CommandeTest.java @@ -48,7 +48,7 @@ public class CommandeTest { int tailleAttendue=2; assertEquals("Test1 taille",tailleAttendue,tailleR); - System.out.println("Cas2 : màj quantité commandée d'une ligne existante"); + /* System.out.println("Cas2 : màj quantité commandée d'une ligne existante"); laCommande.ajouter(instr2, 5); stockRes=instr2.getQteStock(); stockAttendu=4; @@ -56,31 +56,36 @@ public class CommandeTest { /*qteRes=laCommande.getLesLignes().get(instr2); qteAttendu=5; - assertEquals("Test2 quantite", qteAttendu,qteRes);*/ + assertEquals("Test2 quantite", qteAttendu,qteRes); - /*INES*/ + System.out.println("Cas3 : ajout nouvelle ligne avec quantité > stock"); - /*MAISSANE*/ + System.out.println("Cas4 : ajout nouvelle ligne avec quantité 0"); - /*MORGANN*/ + System.out.println("Cas5 : mise à 0 quantité commandée d'une ligne existante"); - /*INES*/ - 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 of supprimer method, of class Commande. - @Test - public void testSupprimer() { - System.out.println("supprimer"); - Instrument unInstrument = null; - Commande instance = null; - boolean expResult = false; - boolean result = instance.supprimer(unInstrument); - assertEquals("test supprimer",expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - }*/ + public void testSupprimer(){ + Instrument instr1 = new Instrument(1,"Piano",10,8300f); + Instrument instr2 = new Instrument(2,"Violon",9,105f); + Commande laCommande2 = new Commande(1,1,"12/09/2024"); + laCommande2.ajouter(instr1,2); + boolean expectedResult=false; + 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); + } + + }