Merge origin/master
# Conflicts: # nbproject/project.properties # src/métiers/Commande.java
This commit is contained in:
parent
b109399da5
commit
c000fb78ee
@ -19,126 +19,6 @@ private int noCom, noVendeur;
|
||||
private String dateCom;
|
||||
|
||||
|
||||
private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
||||
|
||||
|
||||
public Commande(int noCom, int noVendeur, String dateCom) {
|
||||
this.noCom = noCom;
|
||||
this.noVendeur = noVendeur;
|
||||
this.dateCom = dateCom;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ajoute une quantité donnée d'un instrument à la commande
|
||||
* @param unInstrument instrument à ajouter
|
||||
* @param qte quantité à ajouter
|
||||
* @return true si l'ajout est bon
|
||||
*/
|
||||
public boolean ajouter(Instrument unInstrument, int qte){
|
||||
boolean ajoutOK;
|
||||
int qteDisponible = unInstrument.getQteStock();
|
||||
if (qteDisponible<qte){
|
||||
ajoutOK = false;
|
||||
}else {
|
||||
ajoutOK = true;
|
||||
lesLignes.put(unInstrument,qte);
|
||||
unInstrument.setQteStock(qteDisponible-qte);
|
||||
}
|
||||
return ajoutOK;
|
||||
}
|
||||
/**
|
||||
* Supprimer un instrument de la commande
|
||||
* @param unInstrument instrument à supprimer
|
||||
* @return true si la suppression est effectuée
|
||||
*/
|
||||
public boolean supprimer(Instrument unInstrument){
|
||||
//lesLignes.remove(unInstrument);
|
||||
boolean suppOK;
|
||||
if (lesLignes.containsKey(unInstrument) == true){
|
||||
suppOK = true;
|
||||
lesLignes.remove(unInstrument);
|
||||
} else {
|
||||
suppOK = false;
|
||||
}
|
||||
return suppOK;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public int getNoCom() {
|
||||
return noCom;
|
||||
}
|
||||
|
||||
public int getNoVendeur() {
|
||||
return noVendeur;
|
||||
}
|
||||
|
||||
public String getDateCom() {
|
||||
return dateCom;
|
||||
}
|
||||
|
||||
public HashMap<Instrument, Integer> getLesLignes() {
|
||||
return lesLignes;
|
||||
}
|
||||
|
||||
|
||||
public void setNoCom(int noCom) {
|
||||
this.noCom = noCom;
|
||||
}
|
||||
|
||||
public void setNoVendeur(int noVendeur) {
|
||||
this.noVendeur = noVendeur;
|
||||
}
|
||||
|
||||
public void setDateCom(String dateCom) {
|
||||
this.dateCom = dateCom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Commande other = (Commande) obj;
|
||||
if (this.noCom != other.noCom) {
|
||||
return false;
|
||||
}
|
||||
if (this.noVendeur != other.noVendeur) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.dateCom, other.dateCom);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
|
||||
package métiers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ilona
|
||||
*/
|
||||
public class Commande {
|
||||
|
||||
private int noCom, noVendeur;
|
||||
private String dateCom;
|
||||
|
||||
|
||||
private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
||||
|
||||
|
||||
|
@ -5,9 +5,7 @@
|
||||
package métiers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -18,14 +16,14 @@ public class CommandeTest {
|
||||
public CommandeTest() {
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of ajouter method, of class Commande.
|
||||
*/
|
||||
@Test
|
||||
|
||||
public void testAjouter() {
|
||||
Instrument instr1=new Instrument(1,"Piano",10, 8300f);
|
||||
Instrument instr2=new Instrument(2,"Violon",9, 105f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user