Classe test
This commit is contained in:
146
build.xml
146
build.xml
@ -1,73 +1,73 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- You may freely edit this file. See commented blocks below for -->
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
<!-- some examples of how to customize the build. -->
|
<!-- some examples of how to customize the build. -->
|
||||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
<!-- 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="MusicAndCo" default="default" basedir=".">
|
<project name="MusicAndCoV3" default="default" basedir=".">
|
||||||
<description>Builds, tests, and runs the project MusicAndCo.</description>
|
<description>Builds, tests, and runs the project MusicAndCoV3.</description>
|
||||||
<import file="nbproject/build-impl.xml"/>
|
<import file="nbproject/build-impl.xml"/>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
There exist several targets which are by default empty and which can be
|
There exist several targets which are by default empty and which can be
|
||||||
used for execution of your tasks. These targets are usually executed
|
used for execution of your tasks. These targets are usually executed
|
||||||
before and after some main targets. They are:
|
before and after some main targets. They are:
|
||||||
|
|
||||||
-pre-init: called before initialization of project properties
|
-pre-init: called before initialization of project properties
|
||||||
-post-init: called after initialization of project properties
|
-post-init: called after initialization of project properties
|
||||||
-pre-compile: called before javac compilation
|
-pre-compile: called before javac compilation
|
||||||
-post-compile: called after javac compilation
|
-post-compile: called after javac compilation
|
||||||
-pre-compile-single: called before javac compilation of single file
|
-pre-compile-single: called before javac compilation of single file
|
||||||
-post-compile-single: called after javac compilation of single file
|
-post-compile-single: called after javac compilation of single file
|
||||||
-pre-compile-test: called before javac compilation of JUnit tests
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
-post-compile-test: called after javac compilation of JUnit tests
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
-pre-jar: called before JAR building
|
-pre-jar: called before JAR building
|
||||||
-post-jar: called after JAR building
|
-post-jar: called after JAR building
|
||||||
-post-clean: called after cleaning build products
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
(Targets beginning with '-' are not intended to be called on their own.)
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
Example of inserting an obfuscator after compilation could look like this:
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
<target name="-post-compile">
|
<target name="-post-compile">
|
||||||
<obfuscate>
|
<obfuscate>
|
||||||
<fileset dir="${build.classes.dir}"/>
|
<fileset dir="${build.classes.dir}"/>
|
||||||
</obfuscate>
|
</obfuscate>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
For list of available properties check the imported
|
For list of available properties check the imported
|
||||||
nbproject/build-impl.xml file.
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
Another way to customize the build is by overriding existing main targets.
|
Another way to customize the build is by overriding existing main targets.
|
||||||
The targets of interest are:
|
The targets of interest are:
|
||||||
|
|
||||||
-init-macrodef-javac: defines macro for javac compilation
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
-init-macrodef-junit: defines macro for junit execution
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
-init-macrodef-debug: defines macro for class debugging
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
-init-macrodef-java: defines macro for class execution
|
-init-macrodef-java: defines macro for class execution
|
||||||
-do-jar: JAR building
|
-do-jar: JAR building
|
||||||
run: execution of project
|
run: execution of project
|
||||||
-javadoc-build: Javadoc generation
|
-javadoc-build: Javadoc generation
|
||||||
test-report: JUnit report generation
|
test-report: JUnit report generation
|
||||||
|
|
||||||
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="MusicAndCo-impl.jar">
|
<target name="run" depends="MusicAndCoV3-impl.jar">
|
||||||
<exec dir="bin" executable="launcher.exe">
|
<exec dir="bin" executable="launcher.exe">
|
||||||
<arg file="${dist.jar}"/>
|
<arg file="${dist.jar}"/>
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
Notice that the overridden target depends on the jar target and not only on
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
the compile target as the regular run target does. Again, for a list of available
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
properties which you can use, check the target you are overriding in the
|
properties which you can use, check the target you are overriding in the
|
||||||
nbproject/build-impl.xml file.
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
</project>
|
</project>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
|||||||
build.xml.data.CRC32=ad09f6ef
|
build.xml.data.CRC32=0e137893
|
||||||
build.xml.script.CRC32=fbce868f
|
build.xml.script.CRC32=e04698ea
|
||||||
build.xml.stylesheet.CRC32=f85dc8f2@1.109.0.48
|
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.
|
# 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=ad09f6ef
|
nbproject/build-impl.xml.data.CRC32=0e137893
|
||||||
nbproject/build-impl.xml.script.CRC32=4c0de17b
|
nbproject/build-impl.xml.script.CRC32=63f48240
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.109.0.48
|
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.111.0.48
|
||||||
|
@ -1,99 +1,99 @@
|
|||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processor.options=
|
annotation.processing.processor.options=
|
||||||
annotation.processing.processors.list=
|
annotation.processing.processors.list=
|
||||||
annotation.processing.run.all.processors=true
|
annotation.processing.run.all.processors=true
|
||||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||||
build.classes.dir=${build.dir}/classes
|
build.classes.dir=${build.dir}/classes
|
||||||
build.classes.excludes=**/*.java,**/*.form
|
build.classes.excludes=**/*.java,**/*.form
|
||||||
# This directory is removed when the project is cleaned:
|
# This directory is removed when the project is cleaned:
|
||||||
build.dir=build
|
build.dir=build
|
||||||
build.generated.dir=${build.dir}/generated
|
build.generated.dir=${build.dir}/generated
|
||||||
build.generated.sources.dir=${build.dir}/generated-sources
|
build.generated.sources.dir=${build.dir}/generated-sources
|
||||||
# Only compile against the classpath explicitly listed here:
|
# Only compile against the classpath explicitly listed here:
|
||||||
build.sysclasspath=ignore
|
build.sysclasspath=ignore
|
||||||
build.test.classes.dir=${build.dir}/test/classes
|
build.test.classes.dir=${build.dir}/test/classes
|
||||||
build.test.results.dir=${build.dir}/test/results
|
build.test.results.dir=${build.dir}/test/results
|
||||||
# Uncomment to specify the preferred debugger connection transport:
|
# Uncomment to specify the preferred debugger connection transport:
|
||||||
#debug.transport=dt_socket
|
#debug.transport=dt_socket
|
||||||
debug.classpath=\
|
debug.classpath=\
|
||||||
${run.classpath}
|
${run.classpath}
|
||||||
debug.modulepath=\
|
debug.modulepath=\
|
||||||
${run.modulepath}
|
${run.modulepath}
|
||||||
debug.test.classpath=\
|
debug.test.classpath=\
|
||||||
${run.test.classpath}
|
${run.test.classpath}
|
||||||
debug.test.modulepath=\
|
debug.test.modulepath=\
|
||||||
${run.test.modulepath}
|
${run.test.modulepath}
|
||||||
# Files in build.classes.dir which should be excluded from distribution jar
|
# Files in build.classes.dir which should be excluded from distribution jar
|
||||||
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}/MusicAndCo.jar
|
dist.jar=${dist.dir}/MusicAndCoV3.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}/MusicAndCo
|
dist.jlink.output=${dist.jlink.dir}/MusicAndCoV3
|
||||||
excludes=
|
excludes=
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=
|
javac.classpath=
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=\ --enable-preview --enable-preview
|
javac.compilerargs=\ --enable-preview --enable-preview
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
javac.external.vm=true
|
javac.external.vm=true
|
||||||
javac.modulepath=
|
javac.modulepath=
|
||||||
javac.processormodulepath=
|
javac.processormodulepath=
|
||||||
javac.processorpath=\
|
javac.processorpath=\
|
||||||
${javac.classpath}
|
${javac.classpath}
|
||||||
javac.source=21
|
javac.source=21
|
||||||
javac.target=21
|
javac.target=21
|
||||||
javac.test.classpath=\
|
javac.test.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}:\
|
${build.classes.dir}:\
|
||||||
${libs.testng.classpath}:\
|
${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}
|
||||||
javac.test.modulepath=\
|
javac.test.modulepath=\
|
||||||
${javac.modulepath}
|
${javac.modulepath}
|
||||||
javac.test.processorpath=\
|
javac.test.processorpath=\
|
||||||
${javac.test.classpath}
|
${javac.test.classpath}
|
||||||
javadoc.additionalparam=
|
javadoc.additionalparam=
|
||||||
javadoc.author=false
|
javadoc.author=false
|
||||||
javadoc.encoding=${source.encoding}
|
javadoc.encoding=${source.encoding}
|
||||||
javadoc.html5=false
|
javadoc.html5=false
|
||||||
javadoc.noindex=false
|
javadoc.noindex=false
|
||||||
javadoc.nonavbar=false
|
javadoc.nonavbar=false
|
||||||
javadoc.notree=false
|
javadoc.notree=false
|
||||||
javadoc.private=false
|
javadoc.private=false
|
||||||
javadoc.splitindex=true
|
javadoc.splitindex=true
|
||||||
javadoc.use=true
|
javadoc.use=true
|
||||||
javadoc.version=false
|
javadoc.version=false
|
||||||
javadoc.windowtitle=
|
javadoc.windowtitle=
|
||||||
# The jlink additional root modules to resolve
|
# The jlink additional root modules to resolve
|
||||||
jlink.additionalmodules=
|
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=MusicAndCo
|
jlink.launcher.name=MusicAndCoV3
|
||||||
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
|
||||||
mkdist.disabled=false
|
mkdist.disabled=false
|
||||||
platform.active=default_platform
|
platform.active=default_platform
|
||||||
run.classpath=\
|
run.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}
|
${build.classes.dir}
|
||||||
# Space-separated list of JVM arguments used when running the project.
|
# 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.
|
# 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:
|
# To set system properties for unit tests define test-sys-prop.name=value:
|
||||||
run.jvmargs=\ --enable-preview
|
run.jvmargs=\ --enable-preview
|
||||||
run.modulepath=\
|
run.modulepath=\
|
||||||
${javac.modulepath}
|
${javac.modulepath}
|
||||||
run.test.classpath=\
|
run.test.classpath=\
|
||||||
${javac.test.classpath}:\
|
${javac.test.classpath}:\
|
||||||
${build.test.classes.dir}
|
${build.test.classes.dir}
|
||||||
run.test.modulepath=\
|
run.test.modulepath=\
|
||||||
${javac.test.modulepath}
|
${javac.test.modulepath}
|
||||||
source.encoding=UTF-8
|
source.encoding=UTF-8
|
||||||
src.dir=src
|
src.dir=src
|
||||||
test.src.dir=test
|
test.src.dir=test
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
<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>MusicAndCo</name>
|
<name>MusicAndCoV3</name>
|
||||||
<source-roots>
|
<source-roots>
|
||||||
<root id="src.dir"/>
|
<root id="src.dir"/>
|
||||||
</source-roots>
|
</source-roots>
|
||||||
<test-roots>
|
<test-roots>
|
||||||
<root id="test.src.dir"/>
|
<root id="test.src.dir"/>
|
||||||
</test-roots>
|
</test-roots>
|
||||||
</data>
|
</data>
|
||||||
</configuration>
|
</configuration>
|
||||||
</project>
|
</project>
|
||||||
|
63
src/NewClass.java
Normal file
63
src/NewClass.java
Normal file
@ -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<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 métiers.Commande;
|
import java.util.ArrayList;
|
||||||
import métiers.Entreprise;
|
import métiers.*;
|
||||||
import métiers.Instrument;
|
import java.util.Scanner;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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,16 +13,77 @@ import métiers.Instrument;
|
|||||||
* @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) {
|
||||||
Entreprise lEntreprise=new Entreprise("MusicAndCo");
|
Test test1;
|
||||||
Commande laCommande = new Commande(1,1,"12/09/2024");
|
test1 = new Test();
|
||||||
lEntreprise.ajouterCommande(laCommande);
|
int choixUtil=0;
|
||||||
|
while(choixUtil!=3){
|
||||||
//ajouter 3 piano droit et 2 violon alto dans la commande
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,123 +1,130 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package métiers;
|
package métiers;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ilona
|
* @author ilona
|
||||||
*/
|
*/
|
||||||
public class Commande {
|
public class Commande {
|
||||||
|
|
||||||
private int noCom, noVendeur;
|
private int noCom, noVendeur;
|
||||||
private String dateCom;
|
private String dateCom;
|
||||||
|
|
||||||
|
|
||||||
private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public Commande(int noCom, int noVendeur, String dateCom) {
|
public Commande(int noCom, int noVendeur, String dateCom) {
|
||||||
this.noCom = noCom;
|
this.noCom = noCom;
|
||||||
this.noVendeur = noVendeur;
|
this.noVendeur = noVendeur;
|
||||||
this.dateCom = dateCom;
|
this.dateCom = dateCom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajoute une quantité donnée d'un instrument à la commande
|
* Ajoute une quantité donnée d'un instrument à la commande
|
||||||
* @param unInstrument instrument à ajouter
|
* @param unInstrument instrument à ajouter
|
||||||
* @param qte quantité à ajouter
|
* @param qte quantité à ajouter
|
||||||
* @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 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;
|
||||||
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);
|
||||||
unInstrument.setQteStock(qteDisponible-qte);
|
unInstrument.setQteStock(qteDisponible-qte);
|
||||||
}
|
}
|
||||||
return ajoutOK;
|
return ajoutOK;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Supprimer un instrument de la commande
|
* Supprimer un instrument de la commande
|
||||||
* @param unInstrument instrument à supprimer
|
* @param unInstrument instrument à supprimer
|
||||||
* @return true si la suppression est effectuée
|
* @return true si la suppression est effectuée
|
||||||
*/
|
*/
|
||||||
public boolean supprimer(Instrument unInstrument){
|
public boolean supprimer(Instrument unInstrument){
|
||||||
//lesLignes.remove(unInstrument);
|
//lesLignes.remove(unInstrument);
|
||||||
boolean suppOK;
|
|
||||||
if (lesLignes.containsKey(unInstrument) == true){
|
boolean suppOK = false;
|
||||||
suppOK = true;
|
if (lesLignes.containsKey(unInstrument) == true){
|
||||||
lesLignes.remove(unInstrument);
|
suppOK = true;
|
||||||
} else {
|
int qteCommande = lesLignes.get(unInstrument);
|
||||||
suppOK = false;
|
lesLignes.remove(unInstrument);
|
||||||
}
|
int qteDisponible = unInstrument.getQteStock();
|
||||||
return suppOK;
|
unInstrument.setQteStock(qteDisponible+qteCommande);
|
||||||
}
|
}
|
||||||
|
return suppOK;
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
}
|
||||||
|
|
||||||
public int getNoCom() {
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
return noCom;
|
|
||||||
}
|
public int getNoCom() {
|
||||||
|
return noCom;
|
||||||
public int getNoVendeur() {
|
}
|
||||||
return noVendeur;
|
|
||||||
}
|
public int getNoVendeur() {
|
||||||
|
return noVendeur;
|
||||||
public String getDateCom() {
|
}
|
||||||
return dateCom;
|
|
||||||
}
|
public String getDateCom() {
|
||||||
|
return dateCom;
|
||||||
public HashMap<Instrument, Integer> getLesLignes() {
|
}
|
||||||
return lesLignes;
|
|
||||||
}
|
public HashMap<Instrument, Integer> getLesLignes() {
|
||||||
|
return lesLignes;
|
||||||
|
}
|
||||||
public void setNoCom(int noCom) {
|
|
||||||
this.noCom = noCom;
|
|
||||||
}
|
public void setNoCom(int noCom) {
|
||||||
|
this.noCom = noCom;
|
||||||
public void setNoVendeur(int noVendeur) {
|
}
|
||||||
this.noVendeur = noVendeur;
|
|
||||||
}
|
public void setNoVendeur(int noVendeur) {
|
||||||
|
this.noVendeur = noVendeur;
|
||||||
public void setDateCom(String dateCom) {
|
}
|
||||||
this.dateCom = dateCom;
|
|
||||||
}
|
public void setDateCom(String dateCom) {
|
||||||
|
this.dateCom = dateCom;
|
||||||
@Override
|
}
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
@Override
|
||||||
return true;
|
public boolean equals(Object obj) {
|
||||||
}
|
if (this == obj) {
|
||||||
if (obj == null) {
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
if (obj == null) {
|
||||||
if (getClass() != obj.getClass()) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
if (getClass() != obj.getClass()) {
|
||||||
final Commande other = (Commande) obj;
|
return false;
|
||||||
if (this.noCom != other.noCom) {
|
}
|
||||||
return false;
|
final Commande other = (Commande) obj;
|
||||||
}
|
if (this.noCom != other.noCom) {
|
||||||
if (this.noVendeur != other.noVendeur) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
if (this.noVendeur != other.noVendeur) {
|
||||||
return Objects.equals(this.dateCom, other.dateCom);
|
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 + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -15,17 +15,17 @@ import métiers.Instrument;
|
|||||||
public class Entreprise {
|
public class Entreprise {
|
||||||
private String raisonSociale;
|
private String raisonSociale;
|
||||||
private ArrayList<Commande> lesCommandes = new ArrayList<>();
|
private ArrayList<Commande> lesCommandes = new ArrayList<>();
|
||||||
|
private ArrayList<Instrument> lesInstruments = new ArrayList<>();
|
||||||
|
|
||||||
public Entreprise(String raisonSociale) {
|
public Entreprise(String raisonSociale) {
|
||||||
this.raisonSociale = raisonSociale;
|
this.raisonSociale = raisonSociale;
|
||||||
|
|
||||||
ArrayList<Instrument> 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 instr2=new Instrument(54,"Violon Alto",5, 105f);
|
||||||
Instrument instr3=new Instrument(67,"Guitare Classique",8, 575f);
|
Instrument instr3=new Instrument(67,"Guitare Classique",8, 575f);
|
||||||
lesInstruments.add(instr3);
|
|
||||||
lesInstruments.add(instr2);
|
|
||||||
lesInstruments.add(instr1);
|
lesInstruments.add(instr1);
|
||||||
|
lesInstruments.add(instr2);
|
||||||
|
lesInstruments.add(instr3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRaisonSociale() {
|
public String getRaisonSociale() {
|
||||||
@ -40,19 +40,19 @@ public class Entreprise {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "Entreprise{" + "raisonSociale=" + raisonSociale + '}';
|
return "Entreprise{" + "raisonSociale=" + raisonSociale + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ajouterCommande(Commande uneCommande){
|
public void ajouterCommande(Commande uneCommande){
|
||||||
lesCommandes.add(uneCommande);
|
lesCommandes.add(uneCommande);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void supprimerCommande(Commande uneCommande){
|
public void supprimerCommande(Commande uneCommande){
|
||||||
//parcours pour supprimer les instruments de la commande
|
//parcours pour supprimer les instruments de la commande
|
||||||
|
|
||||||
//suppression de la commande
|
//suppression de la commande
|
||||||
lesCommandes.remove(uneCommande);
|
lesCommandes.remove(uneCommande);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Commande rechercherCommande(int noCom){
|
public Commande rechercherCommande(int noCom){
|
||||||
Commande uneCommande = null;
|
Commande uneCommande = null;
|
||||||
for(Commande laCommande : lesCommandes){
|
for(Commande laCommande : lesCommandes){
|
||||||
@ -63,4 +63,23 @@ 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 "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) {
|
public void setRef(int ref) {
|
||||||
|
@ -48,7 +48,7 @@ public class CommandeTest {
|
|||||||
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");
|
/* 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;
|
||||||
@ -56,31 +56,36 @@ public class CommandeTest {
|
|||||||
|
|
||||||
/*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");
|
||||||
/*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");
|
||||||
/*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
|
@Test
|
||||||
public void testSupprimer() {
|
public void testSupprimer(){
|
||||||
System.out.println("supprimer");
|
Instrument instr1 = new Instrument(1,"Piano",10,8300f);
|
||||||
Instrument unInstrument = null;
|
Instrument instr2 = new Instrument(2,"Violon",9,105f);
|
||||||
Commande instance = null;
|
Commande laCommande2 = new Commande(1,1,"12/09/2024");
|
||||||
boolean expResult = false;
|
laCommande2.ajouter(instr1,2);
|
||||||
boolean result = instance.supprimer(unInstrument);
|
boolean expectedResult=false;
|
||||||
assertEquals("test supprimer",expResult, result);
|
boolean expectedResult2=true;
|
||||||
// TODO review the generated test code and remove the default call to fail.
|
int stockAttendu=10;
|
||||||
fail("The test case is a prototype.");
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user