From b5d697a18dd8b5ce6647efb90b4472c9eb9c1938 Mon Sep 17 00:00:00 2001 From: ItsTheSky Date: Mon, 3 Nov 2025 09:33:06 +0100 Subject: [PATCH] Add initial project structure with instrument classes and Gradle setup --- build.gradle | 20 ++ gradlew | 234 ++++++++++++++++++ gradlew.bat | 89 +++++++ settings.gradle | 1 + .../java/net/itsthesky/projetbut2/Main.java | 5 + .../projetbut2/qualdev/ClientGuitar.java | 7 + .../qualdev/FindInstrumentTester_v_Et.java | 90 +++++++ .../projetbut2/qualdev/InstrumentFactory.java | 31 +++ .../projetbut2/qualdev/Inventory.java | 59 +++++ .../qualdev/model/Caracteristique.java | 22 ++ .../projetbut2/qualdev/model/Instrument.java | 64 +++++ .../qualdev/model/InstrumentSpec.java | 50 ++++ .../qualdev/model/common/Builder.java | 14 ++ .../qualdev/model/common/Style.java | 10 + .../projetbut2/qualdev/model/common/Type.java | 8 + .../projetbut2/qualdev/model/common/Wood.java | 17 ++ .../qualdev/model/guitar/Guitar.java | 20 ++ .../qualdev/model/guitar/GuitarSpec.java | 90 +++++++ .../qualdev/model/mandoline/Mandoline.java | 21 ++ .../model/mandoline/MandolineSpec.java | 93 +++++++ 20 files changed, 945 insertions(+) create mode 100644 build.gradle create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle create mode 100644 src/main/java/net/itsthesky/projetbut2/Main.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/ClientGuitar.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/FindInstrumentTester_v_Et.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/InstrumentFactory.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/Inventory.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/Caracteristique.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/Instrument.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/InstrumentSpec.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/common/Builder.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/common/Style.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/common/Type.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/common/Wood.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/guitar/Guitar.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/guitar/GuitarSpec.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/mandoline/Mandoline.java create mode 100644 src/main/java/net/itsthesky/projetbut2/qualdev/model/mandoline/MandolineSpec.java diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..1a2bd36 --- /dev/null +++ b/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'java' +} + +group = 'net.itsthesky.projetbut2' +version = '1.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + testImplementation platform('org.junit:junit-bom:5.10.0') + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..1bfc74e --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'ProjetBUT2' \ No newline at end of file diff --git a/src/main/java/net/itsthesky/projetbut2/Main.java b/src/main/java/net/itsthesky/projetbut2/Main.java new file mode 100644 index 0000000..189ddc1 --- /dev/null +++ b/src/main/java/net/itsthesky/projetbut2/Main.java @@ -0,0 +1,5 @@ +import net.itsthesky.projetbut2.qualdev.FindInstrumentTester_v_Et; + +void main() { + FindInstrumentTester_v_Et.main(new String[]{}); +} \ No newline at end of file diff --git a/src/main/java/net/itsthesky/projetbut2/qualdev/ClientGuitar.java b/src/main/java/net/itsthesky/projetbut2/qualdev/ClientGuitar.java new file mode 100644 index 0000000..37ac763 --- /dev/null +++ b/src/main/java/net/itsthesky/projetbut2/qualdev/ClientGuitar.java @@ -0,0 +1,7 @@ +package net.itsthesky.projetbut2.qualdev; + +/** + * Classe représentant un client de guitare. + */ +public class ClientGuitar { +} diff --git a/src/main/java/net/itsthesky/projetbut2/qualdev/FindInstrumentTester_v_Et.java b/src/main/java/net/itsthesky/projetbut2/qualdev/FindInstrumentTester_v_Et.java new file mode 100644 index 0000000..e613894 --- /dev/null +++ b/src/main/java/net/itsthesky/projetbut2/qualdev/FindInstrumentTester_v_Et.java @@ -0,0 +1,90 @@ +package net.itsthesky.projetbut2.qualdev; + +import net.itsthesky.projetbut2.qualdev.model.common.Builder; +import net.itsthesky.projetbut2.qualdev.model.common.Style; +import net.itsthesky.projetbut2.qualdev.model.common.Type; +import net.itsthesky.projetbut2.qualdev.model.common.Wood; +import net.itsthesky.projetbut2.qualdev.model.guitar.GuitarSpec; +import net.itsthesky.projetbut2.qualdev.model.mandoline.MandolineSpec; + +import java.util.Iterator; +import java.util.List; + +/** + * Classe de test pour rechercher des instruments dans l'inventaire. + */ +public class FindInstrumentTester_v_Et { + + /** + * Point d'entrée principal du programme de test. + * @param args arguments de ligne de commande + */ + public static void main(String[] args) { + // Set up Rick's guitar inventory + Inventory inventory = new Inventory(); + initializeInventory(inventory); + + GuitarSpec whatErinLikes= new GuitarSpec( Builder.FENDER, "Stratocastor", Type.ELECTRIC, + Wood.ALDER, Wood.ALDER, 6); + MandolineSpec whatErinLikes2 = new MandolineSpec(Builder.PRS, "F-5G", Type.ACOUSTIC, Wood.MAPLE, + Wood.MAPLE, Style.A); + List matchingInstruments = inventory.search (whatErinLikes); + + if (!matchingInstruments.isEmpty()) { + System.out.println( matchingInstruments); + } + else { + System.out.println("Sorry, Erin, we have nothing for you."); + } + } + + /** + * Initialise l'inventaire avec des guitares et mandolines de test. + * @param inventory l'inventaire à initialiser + */ + public static void initializeInventory(Inventory inventory) { + + // Ajout des guitares à l'inventaire + inventory.addInstrument("11277", 3999.95, + new GuitarSpec(Builder.COLLINGS, "CJ", Type.ACOUSTIC, + Wood.INDIAN_ROSEWOOD, Wood.SITKA, 6)); + inventory.addInstrument("V95693", 1499.95, + new GuitarSpec(Builder.FENDER, "Stratocastor",Type.ELECTRIC, + Wood.ALDER, Wood.ALDER, 12)); + inventory.addInstrument("V9512", 1549.95, + new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, + Wood.ALDER, Wood.ALDER, 6)); + inventory.addInstrument("122784", 5495.95, + new GuitarSpec(Builder.MARTIN, "D-18", Type.ACOUSTIC, + Wood.MAHOGANY, Wood.ADIRONDACK, 6)); + inventory.addInstrument("76531", 6295.95, + new GuitarSpec(Builder.MARTIN, "OM-28", Type.ACOUSTIC, + Wood.BRAZILIAN_ROSEWOOD, Wood.ADIRONDACK, 6)); + inventory.addInstrument("70108276", 2295.95, + new GuitarSpec(Builder.GIBSON, "Les Paul", Type.ELECTRIC, + Wood.MAHOGANY, Wood.MAHOGANY, 6)); + inventory.addInstrument("82765501", 1890.95, + new GuitarSpec(Builder.GIBSON, "SG '61 Reissue", Type.ELECTRIC, + Wood.MAHOGANY, Wood.MAHOGANY, 6)); + inventory.addInstrument("77023", 6275.95, + new GuitarSpec(Builder.MARTIN, "D-28", Type.ACOUSTIC, + Wood.BRAZILIAN_ROSEWOOD, Wood.ADIRONDACK, 6)); + inventory.addInstrument("1092", 12995.95, + new GuitarSpec(Builder.OLSON, "SJ", Type.ACOUSTIC, + Wood.INDIAN_ROSEWOOD, Wood.CEDAR, 12)); + inventory.addInstrument("566-62", 8999.95, + new GuitarSpec(Builder.RYAN, "Cathedral", Type.ACOUSTIC, + Wood.COCOBOLO, Wood.CEDAR, 12)); + inventory.addInstrument("6 29584", 2100.95, + new GuitarSpec(Builder.PRS, "Dave Navarro Signature", Type.ELECTRIC, + Wood.MAHOGANY, Wood.MAPLE, 6)); + + // Ajout des mandolines à l'inventaire + inventory.addInstrument("8819920", 5495.99 , + new MandolineSpec(Builder.PRS, "F-5G", Type.ACOUSTIC, + Wood.MAPLE, Wood.MAPLE, Style.F)); + inventory.addInstrument("9019920", 745.99 , + new MandolineSpec (Builder.PRS, "F-5G", Type.ACOUSTIC, + Wood.MAPLE, Wood.MAPLE, Style.A)); + } +} diff --git a/src/main/java/net/itsthesky/projetbut2/qualdev/InstrumentFactory.java b/src/main/java/net/itsthesky/projetbut2/qualdev/InstrumentFactory.java new file mode 100644 index 0000000..92b52b2 --- /dev/null +++ b/src/main/java/net/itsthesky/projetbut2/qualdev/InstrumentFactory.java @@ -0,0 +1,31 @@ +package net.itsthesky.projetbut2.qualdev; + +import net.itsthesky.projetbut2.qualdev.model.Instrument; +import net.itsthesky.projetbut2.qualdev.model.InstrumentSpec; +import net.itsthesky.projetbut2.qualdev.model.guitar.Guitar; +import net.itsthesky.projetbut2.qualdev.model.guitar.GuitarSpec; +import net.itsthesky.projetbut2.qualdev.model.mandoline.Mandoline; +import net.itsthesky.projetbut2.qualdev.model.mandoline.MandolineSpec; + +/** + * Factory permettant de créer des instruments de musique en fonction de leurs spécifications. + */ +public class InstrumentFactory { + + /** + * Crée un instrument basé sur son numéro de série, son prix et ses spécifications. + * @param serialNumber le numéro de série de l'instrument + * @param price le prix de l'instrument + * @param instrumentSpec les spécifications de l'instrument + * @return l'instrument créé, ou null si le type de spécification n'est pas reconnu + */ + public static Instrument createInstrument(String serialNumber, double price, InstrumentSpec instrumentSpec) { + if (instrumentSpec instanceof GuitarSpec guitarSpec) + return new Guitar(serialNumber, price, guitarSpec); + if (instrumentSpec instanceof MandolineSpec mandolineSpec) + return new Mandoline(serialNumber, price, mandolineSpec); + + return null; + } + +} diff --git a/src/main/java/net/itsthesky/projetbut2/qualdev/Inventory.java b/src/main/java/net/itsthesky/projetbut2/qualdev/Inventory.java new file mode 100644 index 0000000..84d1a9d --- /dev/null +++ b/src/main/java/net/itsthesky/projetbut2/qualdev/Inventory.java @@ -0,0 +1,59 @@ +package net.itsthesky.projetbut2.qualdev; + +import net.itsthesky.projetbut2.qualdev.model.Instrument; +import net.itsthesky.projetbut2.qualdev.model.InstrumentSpec; + +import java.util.ArrayList; +import java.util.List; + +/** + * Gère l'inventaire des instruments + */ +public class Inventory { + + private final List instruments = new ArrayList<>(); + + /** + * Rajoute un instrument à cet inventaire, basé sur son serial number, + * prix et spécifications. + * @param serialNumber le numéro de série de l'instrument + * @param price le prix de l'instrument + * @param instrumentSpec les spécifications de l'instrument + * @see InstrumentFactory + * @see InstrumentSpec + */ + public void addInstrument(String serialNumber, double price, InstrumentSpec instrumentSpec) { + final var instrument = InstrumentFactory.createInstrument(serialNumber, price, instrumentSpec); + if (instrument != null) + instruments.add(instrument); + } + + /** + * Récupère un instrument de cet instrument basé sur son numéro de série. + * @param serialNumber le numéro de série à chercher + * @return l'instrument trouvé avec le même numéro de série fourni, sinon null + */ + public Instrument getInstrument(String serialNumber) { + return instruments.stream() + .filter(instrument -> instrument.getSerialNumber().equals(serialNumber)) + .findFirst() + .orElse(null); + } + + /** + * Recherche tous les instruments correspondant aux spécifications fournies. + * @param instrumentSpec les spécifications à rechercher + * @return une liste d'instruments correspondant aux spécifications + */ + public List search(InstrumentSpec instrumentSpec) { + final var result = new ArrayList(); + + for (Instrument instrument : instruments) { + if (instrumentSpec.matches(instrument.getInstrumentSpec())) + result.add(instrument); + } + + return result; + } + +} diff --git a/src/main/java/net/itsthesky/projetbut2/qualdev/model/Caracteristique.java b/src/main/java/net/itsthesky/projetbut2/qualdev/model/Caracteristique.java new file mode 100644 index 0000000..633b345 --- /dev/null +++ b/src/main/java/net/itsthesky/projetbut2/qualdev/model/Caracteristique.java @@ -0,0 +1,22 @@ +package net.itsthesky.projetbut2.qualdev.model; + +import net.itsthesky.projetbut2.qualdev.model.common.Builder; +import net.itsthesky.projetbut2.qualdev.model.common.Style; +import net.itsthesky.projetbut2.qualdev.model.common.Type; +import net.itsthesky.projetbut2.qualdev.model.common.Wood; + +public class Caracteristique { + + public static Caracteristique BUILDER = new Caracteristique<>(Builder.class); + public static Caracteristique MODEL = new Caracteristique<>(String.class); + public static Caracteristique NUMBER_OF_STRINGS = new Caracteristique<>(Integer.class); + public static Caracteristique TYPE = new Caracteristique<>(Type.class); + public static Caracteristique WOOD = new Caracteristique<>(Wood.class); + public static Caracteristique