Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16d76d1c08 | |||
| 17d960fd3b | |||
| e580d6995d |
@ -1,5 +1,10 @@
|
||||
import net.itsthesky.projetbut2.qualdev.FindInstrumentTester_v_Et;
|
||||
import net.itsthesky.projetbut2.dip.DIPClient;
|
||||
import net.itsthesky.projetbut2.ocp.OCPClient;
|
||||
|
||||
void main() {
|
||||
FindInstrumentTester_v_Et.main(new String[]{});
|
||||
void main(String[] args) {
|
||||
if (args.length == 0) return;
|
||||
|
||||
if (args[0].equalsIgnoreCase("ocp")) OCPClient.main();
|
||||
else if (args[0].equalsIgnoreCase("dip")) DIPClient.main();
|
||||
else IO.println("Invalid argument: '" + args[0] + "'");
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package net.itsthesky.projetbut2.dip;
|
||||
|
||||
public class BackEndDeveloper implements Developer {
|
||||
|
||||
@Override
|
||||
public void develop() {
|
||||
IO.println("I write Java code !");
|
||||
}
|
||||
|
||||
}
|
||||
10
src/main/java/net/itsthesky/projetbut2/dip/DIPClient.java
Normal file
10
src/main/java/net/itsthesky/projetbut2/dip/DIPClient.java
Normal file
@ -0,0 +1,10 @@
|
||||
package net.itsthesky.projetbut2.dip;
|
||||
|
||||
public final class DIPClient {
|
||||
|
||||
public static void main() {
|
||||
Project project = new Project();
|
||||
project.implement();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package net.itsthesky.projetbut2.dip;
|
||||
|
||||
public interface Developer {
|
||||
|
||||
void develop();
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package net.itsthesky.projetbut2.dip;
|
||||
|
||||
public class FrontEndDeveloper implements Developer{
|
||||
@Override
|
||||
public void develop() {
|
||||
IO.println("I write Javascript code !");
|
||||
}
|
||||
|
||||
}
|
||||
21
src/main/java/net/itsthesky/projetbut2/dip/Project.java
Normal file
21
src/main/java/net/itsthesky/projetbut2/dip/Project.java
Normal file
@ -0,0 +1,21 @@
|
||||
package net.itsthesky.projetbut2.dip;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Project {
|
||||
|
||||
private final List<Developer> developers = new ArrayList<>();
|
||||
|
||||
public Project() {
|
||||
developers.add(new BackEndDeveloper());
|
||||
developers.add(new FrontEndDeveloper());
|
||||
}
|
||||
|
||||
public void implement() {
|
||||
for (var developer : developers) {
|
||||
developer.develop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
import net.itsthesky.projetbut2.ocp.base.Color;
|
||||
import net.itsthesky.projetbut2.ocp.base.Product;
|
||||
|
||||
public class ColorCriteria implements Criteria<Product> {
|
||||
|
||||
private final Color color;
|
||||
public ColorCriteria(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSatisfied(Product product) {
|
||||
return product.color == color;
|
||||
}
|
||||
}
|
||||
7
src/main/java/net/itsthesky/projetbut2/ocp/Criteria.java
Normal file
7
src/main/java/net/itsthesky/projetbut2/ocp/Criteria.java
Normal file
@ -0,0 +1,7 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
public interface Criteria<Product> {
|
||||
|
||||
boolean isSatisfied(Product product);
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
import net.itsthesky.projetbut2.ocp.base.Product;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class MultipleCriteria implements Criteria<Product> {
|
||||
|
||||
private final Criteria<Product>[] criteria;
|
||||
public MultipleCriteria(Criteria<Product>... criteria) {
|
||||
this.criteria = criteria;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSatisfied(Product product) {
|
||||
return Stream.of(criteria).allMatch(c -> c.isSatisfied(product));
|
||||
}
|
||||
}
|
||||
16
src/main/java/net/itsthesky/projetbut2/ocp/NameCriteria.java
Normal file
16
src/main/java/net/itsthesky/projetbut2/ocp/NameCriteria.java
Normal file
@ -0,0 +1,16 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
import net.itsthesky.projetbut2.ocp.base.Product;
|
||||
|
||||
public class NameCriteria implements Criteria<Product> {
|
||||
|
||||
private final String name;
|
||||
public NameCriteria(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSatisfied(Product product) {
|
||||
return product.name.contains(name);
|
||||
}
|
||||
}
|
||||
24
src/main/java/net/itsthesky/projetbut2/ocp/OCPClient.java
Normal file
24
src/main/java/net/itsthesky/projetbut2/ocp/OCPClient.java
Normal file
@ -0,0 +1,24 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
import net.itsthesky.projetbut2.ocp.base.Color;
|
||||
import net.itsthesky.projetbut2.ocp.base.Product;
|
||||
import net.itsthesky.projetbut2.ocp.base.Size;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class OCPClient {
|
||||
|
||||
public static void main() {
|
||||
Product apple = new Product("Apple", Color.GREEN, Size.SMALL);
|
||||
Product tree = new Product("Tree", Color.GREEN, Size.LARGE);
|
||||
Product house = new Product("House", Color.BLUE, Size.LARGE);
|
||||
|
||||
List<Product> products = List.of(apple, tree, house);
|
||||
|
||||
ProductFilter filter = new ProductFilter();
|
||||
System.out.println("Green products : ");
|
||||
filter.filter(products, new MultipleCriteria(new ColorCriteria(Color.GREEN), new SizeCriteria(Size.SMALL)))
|
||||
.forEach(product -> System.out.println(" - " + product.name + " is green and small"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
import net.itsthesky.projetbut2.ocp.base.Product;
|
||||
|
||||
public class PriceRangeCriteria implements Criteria<Product> {
|
||||
|
||||
private final double minPrice;
|
||||
private final double maxPrice;
|
||||
public PriceRangeCriteria(double minPrice, double maxPrice) {
|
||||
this.minPrice = minPrice;
|
||||
this.maxPrice = maxPrice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSatisfied(Product product) {
|
||||
return product.price >= minPrice && product.price <= maxPrice;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
import net.itsthesky.projetbut2.ocp.base.Product;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ProductFilter {
|
||||
|
||||
public Stream<Product> filter(List<Product> products, Criteria<Product> criteria) {
|
||||
return products.stream().filter(criteria::isSatisfied);
|
||||
}
|
||||
|
||||
}
|
||||
17
src/main/java/net/itsthesky/projetbut2/ocp/SizeCriteria.java
Normal file
17
src/main/java/net/itsthesky/projetbut2/ocp/SizeCriteria.java
Normal file
@ -0,0 +1,17 @@
|
||||
package net.itsthesky.projetbut2.ocp;
|
||||
|
||||
import net.itsthesky.projetbut2.ocp.base.Product;
|
||||
import net.itsthesky.projetbut2.ocp.base.Size;
|
||||
|
||||
public class SizeCriteria implements Criteria<Product> {
|
||||
|
||||
private final Size size;
|
||||
public SizeCriteria(Size size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSatisfied(Product product) {
|
||||
return product.size == size;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package net.itsthesky.projetbut2.ocp.base;
|
||||
|
||||
public enum Color {
|
||||
RED, GREEN, BLUE
|
||||
}
|
||||
20
src/main/java/net/itsthesky/projetbut2/ocp/base/Product.java
Normal file
20
src/main/java/net/itsthesky/projetbut2/ocp/base/Product.java
Normal file
@ -0,0 +1,20 @@
|
||||
package net.itsthesky.projetbut2.ocp.base;
|
||||
|
||||
public class Product {
|
||||
|
||||
public String name;
|
||||
public Color color;
|
||||
public Size size;
|
||||
public double price;
|
||||
|
||||
public Product(String name, Color color, Size size, double price) {
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.size = size;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Product(String name, Color color, Size size) {
|
||||
this(name, color, size, 0);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package net.itsthesky.projetbut2.ocp.base;
|
||||
|
||||
public enum Size {
|
||||
SMALL, MEDIUM, LARGE, HUGE
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
package net.itsthesky.projetbut2.qualdev;
|
||||
|
||||
/**
|
||||
* Classe représentant un client de guitare.
|
||||
*/
|
||||
public class ClientGuitar {
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
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<Instrument> 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 <code>null</code>
|
||||
*/
|
||||
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<Instrument> search(InstrumentSpec instrumentSpec) {
|
||||
final var result = new ArrayList<Instrument>();
|
||||
|
||||
for (Instrument instrument : instruments) {
|
||||
if (instrumentSpec.matches(instrument.getInstrumentSpec()))
|
||||
result.add(instrument);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
package net.itsthesky.projetbut2.qualdev.model;
|
||||
|
||||
/**
|
||||
* Classe abstraite représentant un instrument de musique.
|
||||
*/
|
||||
public abstract class Instrument {
|
||||
|
||||
private final String serialNumber;
|
||||
private final InstrumentSpec instrumentSpec;
|
||||
private double price;
|
||||
|
||||
/**
|
||||
* Constructeur d'un instrument.
|
||||
* @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
|
||||
*/
|
||||
public Instrument(String serialNumber, double price, InstrumentSpec instrumentSpec) {
|
||||
this.serialNumber = serialNumber;
|
||||
this.instrumentSpec = instrumentSpec;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère le numéro de série de l'instrument.
|
||||
* @return le numéro de série
|
||||
*/
|
||||
public String getSerialNumber() {
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les spécifications de l'instrument.
|
||||
* @return les spécifications
|
||||
*/
|
||||
public InstrumentSpec getInstrumentSpec() {
|
||||
return instrumentSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère le prix de l'instrument.
|
||||
* @return le prix
|
||||
*/
|
||||
public double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifie le prix de l'instrument.
|
||||
* @param price le nouveau prix
|
||||
*/
|
||||
public void setPrice(double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Instrument{" +
|
||||
"serialNumber='" + serialNumber + '\'' +
|
||||
", instrumentSpec=" + instrumentSpec +
|
||||
", price=" + price +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package net.itsthesky.projetbut2.qualdev.model;
|
||||
|
||||
import net.itsthesky.projetbut2.qualdev.model.common.Wood;
|
||||
|
||||
/**
|
||||
* Classe abstraite représentant les spécifications d'un instrument de musique.
|
||||
*/
|
||||
public abstract class InstrumentSpec {
|
||||
|
||||
private final Wood topWood;
|
||||
private final Wood backWood;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this.topWood = topWood;
|
||||
this.backWood = backWood;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si ces spécifications correspondent à d'autres spécifications.
|
||||
* @param otherSpec les spécifications à comparer
|
||||
* @return <code>true</code> si les spécifications correspondent, <code>false</code> sinon
|
||||
*/
|
||||
public boolean matches(InstrumentSpec otherSpec) {
|
||||
if (otherSpec == null) return false;
|
||||
if (topWood != otherSpec.topWood) return false;
|
||||
if (backWood != otherSpec.backWood) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère le type de bois de la face supérieure.
|
||||
* @return le type de bois supérieur
|
||||
*/
|
||||
public Wood getTopWood() {
|
||||
return topWood;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère le type de bois de la face arrière.
|
||||
* @return le type de bois arrière
|
||||
*/
|
||||
public Wood getBackWood() {
|
||||
return backWood;
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
||||
|
||||
/**
|
||||
* Représente un constructeur d'instrument de musique.
|
||||
*/
|
||||
public enum Builder {
|
||||
COLLINGS,
|
||||
FENDER,
|
||||
GIBSON,
|
||||
MARTIN,
|
||||
OLSON,
|
||||
RYAN,
|
||||
PRS
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
||||
|
||||
/**
|
||||
* Représente le style d'une {@link net.itsthesky.projetbut2.qualdev.model.mandoline.MandolineSpec mandoline}; A pour
|
||||
* Acoustique et F pour Fender.
|
||||
*/
|
||||
public enum Style {
|
||||
A,
|
||||
F
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
||||
|
||||
/**
|
||||
* Représent le type d'une {@link net.itsthesky.projetbut2.qualdev.model.guitar.GuitarSpec guitar}.
|
||||
*/
|
||||
public enum Type {
|
||||
ACOUSTIC, ELECTRIC
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package net.itsthesky.projetbut2.qualdev.model.common;
|
||||
|
||||
/**
|
||||
* Représente le type de bois utilisé dans la confection
|
||||
* de l'{@link net.itsthesky.projetbut2.qualdev.model.Instrument instrument}.
|
||||
*/
|
||||
public enum Wood {
|
||||
ADIRONDACK,
|
||||
CEDAR,
|
||||
COCOBOLO,
|
||||
MAHOGANY,
|
||||
MAPLE,
|
||||
SITKA,
|
||||
ALDER,
|
||||
BRAZILIAN_ROSEWOOD,
|
||||
INDIAN_ROSEWOOD
|
||||
}
|
||||
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user