Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e580d6995d |
@ -1,5 +1,5 @@
|
|||||||
import net.itsthesky.projetbut2.qualdev.FindInstrumentTester_v_Et;
|
import net.itsthesky.projetbut2.qualdev.FindInstrumentTester;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
FindInstrumentTester_v_Et.main(new String[]{});
|
FindInstrumentTester.main(new String[]{});
|
||||||
}
|
}
|
||||||
@ -1,7 +0,0 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Classe représentant un client de guitare.
|
|
||||||
*/
|
|
||||||
public class ClientGuitar {
|
|
||||||
}
|
|
||||||
@ -0,0 +1,115 @@
|
|||||||
|
package net.itsthesky.projetbut2.qualdev;
|
||||||
|
|
||||||
|
import net.itsthesky.projetbut2.qualdev.model.Specification;
|
||||||
|
import net.itsthesky.projetbut2.qualdev.model.Instrument;
|
||||||
|
import net.itsthesky.projetbut2.qualdev.model.InstrumentSpec;
|
||||||
|
import net.itsthesky.projetbut2.qualdev.model.specs.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FindInstrumentTester {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Set up Rick's inventory
|
||||||
|
Inventory inventory = new Inventory();
|
||||||
|
initializeInventory(inventory);
|
||||||
|
|
||||||
|
|
||||||
|
InstrumentSpec whatBryanLikes = new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.MANDOLIN,
|
||||||
|
Specification.STYLE, Style.F));
|
||||||
|
|
||||||
|
whatBryanLikes = new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.BANJO));
|
||||||
|
|
||||||
|
List matchingInstruments = inventory.search(whatBryanLikes);
|
||||||
|
if (!matchingInstruments.isEmpty())
|
||||||
|
System.out.println("Here's what we have for you:\n" + matchingInstruments);
|
||||||
|
else
|
||||||
|
System.out.println("Sorry, we have nothing for you.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void initializeInventory(Inventory inventory) {
|
||||||
|
inventory.addInstrument(new Instrument("82765501", 1890.95,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.GUITAR,
|
||||||
|
Specification.TYPE, Type.ELECTRIC,
|
||||||
|
Specification.MODEL, "SG '61 Reissue",
|
||||||
|
Specification.BACKWOOD, Wood.MAHOGANY,
|
||||||
|
Specification.TOPWOOD, Wood.MAHOGANY))));
|
||||||
|
|
||||||
|
inventory.addInstrument(new Instrument("9019920", 5495.99,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.MANDOLIN,
|
||||||
|
Specification.TYPE, Type.ACOUSTIC,
|
||||||
|
Specification.MODEL, "DRSM-008 E",
|
||||||
|
Specification.BACKWOOD, Wood.MAPLE,
|
||||||
|
Specification.TOPWOOD, Wood.MAPLE,
|
||||||
|
Specification.BUILDER, Builder.PRS,
|
||||||
|
Specification.STYLE, Style.A
|
||||||
|
))));
|
||||||
|
|
||||||
|
inventory.addInstrument(new Instrument("7819920", 549,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.MANDOLIN,
|
||||||
|
Specification.TYPE, Type.ACOUSTIC,
|
||||||
|
Specification.MODEL, "F-5G",
|
||||||
|
Specification.BACKWOOD, Wood.MAPLE,
|
||||||
|
Specification.TOPWOOD, Wood.MAPLE,
|
||||||
|
Specification.BUILDER, Builder.GIBSON,
|
||||||
|
Specification.STYLE, Style.F
|
||||||
|
))));
|
||||||
|
inventory.addInstrument(new Instrument("8900231", 2945.95,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.BANJO,
|
||||||
|
Specification.MODEL, "RB-3 Wreath",
|
||||||
|
Specification.YEAR_OF_MANUFACTURE, 1967
|
||||||
|
))));
|
||||||
|
inventory.addInstrument(new Instrument("70108276", 2295.95,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.GUITAR,
|
||||||
|
Specification.BUILDER, Builder.GIBSON,
|
||||||
|
Specification.MODEL, "Les Paul",
|
||||||
|
Specification.BACKWOOD, Wood.MAPLE,
|
||||||
|
Specification.TOPWOOD, Wood.MAPLE
|
||||||
|
))));
|
||||||
|
inventory.addInstrument(new Instrument("V95693", 1499.95,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.GUITAR,
|
||||||
|
Specification.BUILDER, Builder.FENDER,
|
||||||
|
Specification.MODEL, "Stratocastor",
|
||||||
|
Specification.BACKWOOD, Wood.ALDER,
|
||||||
|
Specification.TOPWOOD, Wood.ALDER,
|
||||||
|
Specification.TYPE, Type.ELECTRIC
|
||||||
|
))));
|
||||||
|
inventory.addInstrument(new Instrument("V9512", 1549.95,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.GUITAR,
|
||||||
|
Specification.BUILDER, Builder.FENDER,
|
||||||
|
Specification.MODEL, "Stratocastor",
|
||||||
|
Specification.BACKWOOD, Wood.ALDER,
|
||||||
|
Specification.TOPWOOD, Wood.ALDER,
|
||||||
|
Specification.TYPE, Type.ELECTRIC
|
||||||
|
))));
|
||||||
|
inventory.addInstrument(new Instrument("122784", 5495.95,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.GUITAR,
|
||||||
|
Specification.BUILDER, Builder.MARTIN,
|
||||||
|
Specification.MODEL, "D-18",
|
||||||
|
Specification.BACKWOOD, Wood.MAHOGANY,
|
||||||
|
Specification.TOPWOOD, Wood.ADIRONDACK
|
||||||
|
))));
|
||||||
|
inventory.addInstrument(new Instrument("11277", 3999.95,
|
||||||
|
new InstrumentSpec(Arrays.asList(
|
||||||
|
Specification.INSTRUMENT_TYPE, InstrumentType.GUITAR,
|
||||||
|
Specification.BUILDER, Builder.COLLINGS,
|
||||||
|
Specification.MODEL, "CJ",
|
||||||
|
Specification.BACKWOOD, Wood.INDIAN_ROSEWOOD,
|
||||||
|
Specification.TOPWOOD, Wood.SITKA,
|
||||||
|
Specification.TYPE, Type.ACOUSTIC,
|
||||||
|
Specification.NUMBER_OF_STRINGS, 6
|
||||||
|
))));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,90 +0,0 @@
|
|||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
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 <code>null</code> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -16,16 +16,11 @@ public class Inventory {
|
|||||||
/**
|
/**
|
||||||
* Rajoute un instrument à cet inventaire, basé sur son serial number,
|
* Rajoute un instrument à cet inventaire, basé sur son serial number,
|
||||||
* prix et spécifications.
|
* prix et spécifications.
|
||||||
* @param serialNumber le numéro de série de l'instrument
|
* @param instrument l'instrument à ajouter
|
||||||
* @param price le prix de l'instrument
|
|
||||||
* @param instrumentSpec les spécifications de l'instrument
|
|
||||||
* @see InstrumentFactory
|
|
||||||
* @see InstrumentSpec
|
* @see InstrumentSpec
|
||||||
*/
|
*/
|
||||||
public void addInstrument(String serialNumber, double price, InstrumentSpec instrumentSpec) {
|
public void addInstrument(Instrument instrument) {
|
||||||
final var instrument = InstrumentFactory.createInstrument(serialNumber, price, instrumentSpec);
|
instruments.add(instrument);
|
||||||
if (instrument != null)
|
|
||||||
instruments.add(instrument);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
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<T> {
|
|
||||||
|
|
||||||
public static Caracteristique<Builder> BUILDER = new Caracteristique<>(Builder.class);
|
|
||||||
public static Caracteristique<String> MODEL = new Caracteristique<>(String.class);
|
|
||||||
public static Caracteristique<Integer> NUMBER_OF_STRINGS = new Caracteristique<>(Integer.class);
|
|
||||||
public static Caracteristique<Type> TYPE = new Caracteristique<>(Type.class);
|
|
||||||
public static Caracteristique<Wood> WOOD = new Caracteristique<>(Wood.class);
|
|
||||||
public static Caracteristique<Style> STYLE = new Caracteristique<>(Style.class);
|
|
||||||
|
|
||||||
private final Class<T> type;
|
|
||||||
|
|
||||||
public Caracteristique(Class<T> type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ package net.itsthesky.projetbut2.qualdev.model;
|
|||||||
/**
|
/**
|
||||||
* Classe abstraite représentant un instrument de musique.
|
* Classe abstraite représentant un instrument de musique.
|
||||||
*/
|
*/
|
||||||
public abstract class Instrument {
|
public class Instrument {
|
||||||
|
|
||||||
private final String serialNumber;
|
private final String serialNumber;
|
||||||
private final InstrumentSpec instrumentSpec;
|
private final InstrumentSpec instrumentSpec;
|
||||||
|
|||||||
@ -1,23 +1,34 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model;
|
package net.itsthesky.projetbut2.qualdev.model;
|
||||||
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.common.Wood;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe abstraite représentant les spécifications d'un instrument de musique.
|
* Classe abstraite représentant les spécifications d'un instrument de musique.
|
||||||
*/
|
*/
|
||||||
public abstract class InstrumentSpec {
|
public class InstrumentSpec {
|
||||||
|
|
||||||
private final Wood topWood;
|
private final Map<Specification<?>, Object> caracteristiques;
|
||||||
private final Wood backWood;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur des spécifications de l'instrument.
|
* Constructeur des spécifications de l'instrument.
|
||||||
* @param topWood le type de bois de la face supérieure
|
|
||||||
* @param backWood le type de bois de la face arrière
|
|
||||||
*/
|
*/
|
||||||
protected InstrumentSpec(Wood topWood, Wood backWood) {
|
public InstrumentSpec() {
|
||||||
this.topWood = topWood;
|
this.caracteristiques = new HashMap<>();
|
||||||
this.backWood = backWood;
|
}
|
||||||
|
|
||||||
|
public InstrumentSpec(List<Object> specs) {
|
||||||
|
this.caracteristiques = new HashMap<>();
|
||||||
|
for (int i = 0; i < specs.size(); i += 2) {
|
||||||
|
Specification<?> key = (Specification<?>) specs.get(i);
|
||||||
|
Object value = specs.get(i + 1);
|
||||||
|
|
||||||
|
if (value.getClass() != key.type())
|
||||||
|
throw new IllegalArgumentException("Type de valeur incorrect pour la caractéristique " + key.label());
|
||||||
|
|
||||||
|
this.caracteristiques.put(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,24 +38,32 @@ public abstract class InstrumentSpec {
|
|||||||
*/
|
*/
|
||||||
public boolean matches(InstrumentSpec otherSpec) {
|
public boolean matches(InstrumentSpec otherSpec) {
|
||||||
if (otherSpec == null) return false;
|
if (otherSpec == null) return false;
|
||||||
if (topWood != otherSpec.topWood) return false;
|
for (var caracteristique : caracteristiques.entrySet()) {
|
||||||
if (backWood != otherSpec.backWood) return false;
|
var otherValue = otherSpec.caracteristiques.get(caracteristique.getKey());
|
||||||
|
if (otherValue == null || !caracteristique.getValue().equals(otherValue)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Map<Specification<?>, ?> getCaracteristiques() {
|
||||||
* Récupère le type de bois de la face supérieure.
|
return caracteristiques;
|
||||||
* @return le type de bois supérieur
|
|
||||||
*/
|
|
||||||
public Wood getTopWood() {
|
|
||||||
return topWood;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public <T> T getCaracteristique(Specification<T> specification) {
|
||||||
* Récupère le type de bois de la face arrière.
|
return (T) caracteristiques.get(specification);
|
||||||
* @return le type de bois arrière
|
}
|
||||||
*/
|
|
||||||
public Wood getBackWood() {
|
public <T> InstrumentSpec addCaracteristique(Specification<T> specification, T value) {
|
||||||
return backWood;
|
this.caracteristiques.put(specification, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InstrumentSpec{" +
|
||||||
|
"caracteristiques=" + caracteristiques +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
package net.itsthesky.projetbut2.qualdev.model;
|
||||||
|
|
||||||
|
import net.itsthesky.projetbut2.qualdev.model.specs.*;
|
||||||
|
|
||||||
|
public record Specification<T>(Class<T> type, String label) {
|
||||||
|
|
||||||
|
public static Specification<Builder> BUILDER = new Specification<>(Builder.class, "Fabricantt");
|
||||||
|
public static Specification<String> MODEL = new Specification<>(String.class, "Modèle");
|
||||||
|
public static Specification<Integer> NUMBER_OF_STRINGS = new Specification<>(Integer.class, "Nombre de cordes");
|
||||||
|
public static Specification<Type> TYPE = new Specification<>(Type.class, "Type");
|
||||||
|
public static Specification<Style> STYLE = new Specification<>(Style.class, "Style");
|
||||||
|
public static Specification<Integer> YEAR_OF_MANUFACTURE = new Specification<>(Integer.class, "Année de fabrication");
|
||||||
|
|
||||||
|
public static Specification<Wood> TOPWOOD = new Specification<>(Wood.class, "Bois dessus");
|
||||||
|
public static Specification<Wood> BACKWOOD = new Specification<>(Wood.class, "Bois dessous");
|
||||||
|
|
||||||
|
public static Specification<InstrumentType> INSTRUMENT_TYPE = new Specification<>(InstrumentType.class, "Type d'instrument");
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.guitar;
|
|
||||||
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.Instrument;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Représente une guitare, un type spécifique d'instrument de musique.
|
|
||||||
*/
|
|
||||||
public class Guitar extends Instrument {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructeur d'une guitare.
|
|
||||||
* @param serialNumber le numéro de série de la guitare
|
|
||||||
* @param price le prix de la guitare
|
|
||||||
* @param instrumentSpec les spécifications de la guitare
|
|
||||||
*/
|
|
||||||
public Guitar(String serialNumber, double price, GuitarSpec instrumentSpec) {
|
|
||||||
super(serialNumber, price, instrumentSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,90 +0,0 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.guitar;
|
|
||||||
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.InstrumentSpec;
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.common.Builder;
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.common.Type;
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.common.Wood;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Représente les spécifications d'une guitare.
|
|
||||||
*/
|
|
||||||
public class GuitarSpec extends InstrumentSpec {
|
|
||||||
|
|
||||||
private final Builder builder;
|
|
||||||
private final int numStrings;
|
|
||||||
private final String model;
|
|
||||||
private final Type type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructeur des spécifications d'une guitare.
|
|
||||||
* @param builder le constructeur de la guitare
|
|
||||||
* @param model le modèle de la guitare
|
|
||||||
* @param type le type de guitare (acoustique ou électrique)
|
|
||||||
* @param topWood le type de bois de la face supérieure
|
|
||||||
* @param backWood le type de bois de la face arrière
|
|
||||||
* @param numStrings le nombre de cordes
|
|
||||||
*/
|
|
||||||
public GuitarSpec(Builder builder, String model, Type type, Wood topWood, Wood backWood, int numStrings) {
|
|
||||||
super(topWood, backWood);
|
|
||||||
this.builder = builder;
|
|
||||||
this.numStrings = numStrings;
|
|
||||||
this.model = model;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le constructeur de la guitare.
|
|
||||||
* @return le constructeur
|
|
||||||
*/
|
|
||||||
public Builder getBuilder() {
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le nombre de cordes de la guitare.
|
|
||||||
* @return le nombre de cordes
|
|
||||||
*/
|
|
||||||
public int getNumStrings() {
|
|
||||||
return numStrings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le type de guitare.
|
|
||||||
* @return le type (acoustique ou électrique)
|
|
||||||
*/
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InstrumentSpec otherSpec) {
|
|
||||||
if (!super.matches(otherSpec)) return false;
|
|
||||||
if (otherSpec instanceof GuitarSpec otherGuitarSpec) {
|
|
||||||
if (builder != otherGuitarSpec.builder) return false;
|
|
||||||
if (numStrings != otherGuitarSpec.numStrings) return false;
|
|
||||||
if (type != otherGuitarSpec.type) return false;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le modèle de la guitare.
|
|
||||||
* @return le modèle
|
|
||||||
*/
|
|
||||||
public String getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "GuitarSpec{" +
|
|
||||||
"builder=" + builder +
|
|
||||||
", numStrings=" + numStrings +
|
|
||||||
", model='" + model + '\'' +
|
|
||||||
", type=" + type +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.mandoline;
|
|
||||||
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.Instrument;
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.InstrumentSpec;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Représente une mandoline, un type spécifique d'instrument de musique.
|
|
||||||
*/
|
|
||||||
public class Mandoline extends Instrument {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructeur d'une mandoline.
|
|
||||||
* @param serialNumber le numéro de série de la mandoline
|
|
||||||
* @param price le prix de la mandoline
|
|
||||||
* @param instrumentSpec les spécifications de la mandoline
|
|
||||||
*/
|
|
||||||
public Mandoline(String serialNumber, double price, MandolineSpec instrumentSpec) {
|
|
||||||
super(serialNumber, price, instrumentSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,93 +0,0 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.mandoline;
|
|
||||||
|
|
||||||
import net.itsthesky.projetbut2.qualdev.model.InstrumentSpec;
|
|
||||||
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 java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Représente les spécifications d'une mandoline.
|
|
||||||
*/
|
|
||||||
public class MandolineSpec extends InstrumentSpec {
|
|
||||||
|
|
||||||
private final Style style;
|
|
||||||
private final Builder builder;
|
|
||||||
private final String model;
|
|
||||||
private final Type type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructeur des spécifications d'une mandoline.
|
|
||||||
* @param builder le constructeur de la mandoline
|
|
||||||
* @param model le modèle de la mandoline
|
|
||||||
* @param type le type de mandoline (acoustique ou électrique)
|
|
||||||
* @param topWood le type de bois de la face supérieure
|
|
||||||
* @param backWood le type de bois de la face arrière
|
|
||||||
* @param style le style de la mandoline (A ou F)
|
|
||||||
*/
|
|
||||||
public MandolineSpec(Builder builder, String model, Type type, Wood topWood, Wood backWood, Style style) {
|
|
||||||
super(topWood, backWood);
|
|
||||||
this.style = style;
|
|
||||||
this.builder = builder;
|
|
||||||
this.model = model;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le style de la mandoline.
|
|
||||||
* @return le style (A ou F)
|
|
||||||
*/
|
|
||||||
public Style getStyle() {
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le constructeur de la mandoline.
|
|
||||||
* @return le constructeur
|
|
||||||
*/
|
|
||||||
public Builder getBuilder() {
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le modèle de la mandoline.
|
|
||||||
* @return le modèle
|
|
||||||
*/
|
|
||||||
public String getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère le type de mandoline.
|
|
||||||
* @return le type (acoustique ou électrique)
|
|
||||||
*/
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InstrumentSpec otherSpec) {
|
|
||||||
if (!super.matches(otherSpec)) return false;
|
|
||||||
if (otherSpec instanceof MandolineSpec otherMandolineSpec) {
|
|
||||||
if (style != otherMandolineSpec.style) return false;
|
|
||||||
if (builder != otherMandolineSpec.builder) return false;
|
|
||||||
if (!Objects.equals(model, otherMandolineSpec.model)) return false;
|
|
||||||
if (type != otherMandolineSpec.type) return false;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "MandolineSpec{" +
|
|
||||||
"style=" + style +
|
|
||||||
", builder=" + builder +
|
|
||||||
", model='" + model + '\'' +
|
|
||||||
", type=" + type +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
package net.itsthesky.projetbut2.qualdev.model.specs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Représente un constructeur d'instrument de musique.
|
* Représente un constructeur d'instrument de musique.
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package net.itsthesky.projetbut2.qualdev.model.specs;
|
||||||
|
|
||||||
|
public enum InstrumentType {
|
||||||
|
|
||||||
|
GUITAR, MANDOLIN, CELLO, BANJO, VIOLIN, DOBRO, FIDDLE, BASS, ;
|
||||||
|
|
||||||
|
public String toString () {
|
||||||
|
|
||||||
|
return this.name().toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
package net.itsthesky.projetbut2.qualdev.model.specs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Représente le style d'une {@link net.itsthesky.projetbut2.qualdev.model.mandoline.MandolineSpec mandoline}; A pour
|
* Représente le style d'une {@link net.itsthesky.projetbut2.qualdev.model.mandoline.MandolineSpec mandoline}; A pour
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
package net.itsthesky.projetbut2.qualdev.model.specs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Représent le type d'une {@link net.itsthesky.projetbut2.qualdev.model.guitar.GuitarSpec guitar}.
|
* Représent le type d'une {@link net.itsthesky.projetbut2.qualdev.model.guitar.GuitarSpec guitar}.
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
package net.itsthesky.projetbut2.qualdev.model.specs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Représente le type de bois utilisé dans la confection
|
* Représente le type de bois utilisé dans la confection
|
||||||
Reference in New Issue
Block a user