Compare commits
2 Commits
morgannV2B
...
Maissane2
Author | SHA1 | Date | |
---|---|---|---|
bcfeae501b | |||
eb90f67599 |
@ -1,4 +1,5 @@
|
||||
|
||||
import java.util.Scanner;
|
||||
import métiers.Commande;
|
||||
import métiers.Entreprise;
|
||||
import métiers.Instrument;
|
||||
@ -10,50 +11,88 @@ import métiers.Instrument;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sio
|
||||
* @author Maissane
|
||||
*/
|
||||
public class Test {
|
||||
|
||||
public class Test {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
//condition pour une premiere commande et si il y en a d'autre
|
||||
boolean choix = false;
|
||||
System.out.println("Voulez vous passer une commande ? oui = true /non = false ");
|
||||
Scanner v = new Scanner(System.in);
|
||||
boolean choixutili = v.nextBoolean();
|
||||
while(choixutili)
|
||||
{
|
||||
|
||||
Entreprise lEntreprise=new Entreprise("MusicAndCo");
|
||||
Commande laCommande1 = new Commande(1,1,"26/09/2024");
|
||||
//Afficher les instruments disponibles
|
||||
for(Instrument unInstrument : lEntreprise.getLesInstruments()){
|
||||
System.out.println(unInstrument.toString());
|
||||
}
|
||||
System.out.println("---");
|
||||
|
||||
int i = 0;
|
||||
//ajouter des instruments de l'entreprise à la commande
|
||||
laCommande1.ajouter(lEntreprise.getLesInstruments().get(0), 2);
|
||||
laCommande1.ajouter(lEntreprise.getLesInstruments().get(1), 3);
|
||||
System.out.println("\t--- BIENVENUE CHEZ MUSIC&CO --- ");
|
||||
System.out.println("\tVoici la liste des instruments en vente : ");
|
||||
// ArrayList<Instrument> lesInstruments = new ArrayList<>();
|
||||
for(Instrument instruments : lEntreprise.getLesInstruments() ){
|
||||
i = i+1;
|
||||
System.out.println(i);
|
||||
System.out.println("\t\n" + instruments + "\t\n");
|
||||
}
|
||||
System.out.println("--- Quel(s) instrument(s) souhaitez vous acheter ? Saisisez le numero du menu ---");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int index = sc.nextInt();
|
||||
System.out.println("Vous avez saisi : " + index);
|
||||
System.out.println(" indiquer la quantitée souhaitée: ");
|
||||
int qte = sc.nextInt() ;//innitialiser la variable qte a 0
|
||||
// String.valueOf(qte); //convertir la variable int en String
|
||||
// str = sc.nextLine(); //saisie de la saisie clavier de l'utilisateur
|
||||
|
||||
// System.out.println(index) ;
|
||||
|
||||
System.out.println( lEntreprise.getLesInstruments().get(index-1)) ; //affiche le produit choisi
|
||||
laCommande1.ajouter(lEntreprise.getLesInstruments().get(index-1), qte); //ajout de l'instrument à la commande
|
||||
// System.out.println("Voici votre panier : " + laCommande1.toString()); //afficher la commande
|
||||
// System.out.println("Voici votre panier : " + lEntreprise. ); //afficher la commande
|
||||
System.out.println("Instrument choisi = " + lEntreprise.getLesInstruments().get(index-1).getDesignation()); //affichage de la designation de l'instrument choisi
|
||||
System.out.println("Quantité choisi = " + qte); //affichage de la qté choisi de l'utilisateur
|
||||
System.out.println("Date de votre commande: " + laCommande1.getDateCom()); //affichage de la date de la commande
|
||||
System.out.println("Nombre de panier : " + laCommande1.getNoCom()); //affichage du numero de la commande
|
||||
// laCommande1.ajouter(index, qte); //methode pour ajouter la commande pas fini
|
||||
|
||||
System.out.println("Souhaitez vous rajouter des articles dans votre commande ? "); //demander à l'utilisateur si il veut rajouter des articles
|
||||
v = new Scanner(System.in);
|
||||
choixutili = v.nextBoolean();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//affecter la commande à l'entreprise si la comamnde est possible
|
||||
lEntreprise.ajouterCommande(laCommande1);
|
||||
for(Instrument unInstrument : lEntreprise.getLesInstruments()){
|
||||
System.out.println(unInstrument.toString());
|
||||
}
|
||||
System.out.println("---");
|
||||
// lEntreprise.ajouterCommande(laCommande1);
|
||||
|
||||
//créer une autre commande
|
||||
Commande laCommande2 = new Commande(2,1,"26/09/2024");
|
||||
laCommande2.ajouter(lEntreprise.getLesInstruments().get(0), 1);
|
||||
laCommande2.ajouter(lEntreprise.getLesInstruments().get(1), 1);
|
||||
laCommande2.ajouter(lEntreprise.getLesInstruments().get(2), 5);
|
||||
lEntreprise.ajouterCommande(laCommande2);
|
||||
for(Instrument unInstrument : lEntreprise.getLesInstruments()){
|
||||
System.out.println(unInstrument.toString());
|
||||
}
|
||||
System.out.println("---");
|
||||
Commande laCommande2 = new Commande(2,2,"26/09/2024");
|
||||
|
||||
//rechercher et afficher une commande
|
||||
// System.out.println( laCommande1.toString());
|
||||
// System.out.println( laCommande2.toString());
|
||||
|
||||
//supprimer une des 2 commande
|
||||
|
||||
//supprimer une des 2 commandes
|
||||
//laCommande2 = null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,13 +82,6 @@ private final HashMap<Instrument, Integer> lesLignes = new HashMap<>();
|
||||
boolean suppOK;
|
||||
if (lesLignes.containsKey(unInstrument) == true){
|
||||
suppOK = true;
|
||||
//mettre le stock à jour
|
||||
//récupération de la quantité en stock
|
||||
int oldQte=unInstrument.getQteStock();
|
||||
//réaffectation dans le stock de la quantité commandée
|
||||
int qteStock=oldQte+ this.getLesLignes().get(unInstrument);
|
||||
unInstrument.setQteStock(qteStock);
|
||||
//suppression ligne commande
|
||||
lesLignes.remove(unInstrument);
|
||||
} else {
|
||||
suppOK = false;
|
||||
|
@ -23,9 +23,9 @@ public class Entreprise {
|
||||
Instrument instr1=new Instrument(23,"Piano droit",3, 8300f);
|
||||
Instrument instr2=new Instrument(54,"Violon Alto",5, 105f);
|
||||
Instrument instr3=new Instrument(67,"Guitare Classique",8, 575f);
|
||||
lesInstruments.add(instr1);
|
||||
lesInstruments.add(instr2);
|
||||
lesInstruments.add(instr3);
|
||||
lesInstruments.add(instr2);
|
||||
lesInstruments.add(instr1);
|
||||
}
|
||||
|
||||
public String getRaisonSociale() {
|
||||
@ -64,9 +64,20 @@ public class Entreprise {
|
||||
return uneCommande;
|
||||
}
|
||||
|
||||
public ArrayList<Commande> getLesCommandes() {
|
||||
return lesCommandes;
|
||||
}
|
||||
|
||||
public void setLesCommandes(ArrayList<Commande> lesCommandes) {
|
||||
this.lesCommandes = lesCommandes;
|
||||
}
|
||||
|
||||
public ArrayList<Instrument> getLesInstruments() {
|
||||
return lesInstruments;
|
||||
}
|
||||
|
||||
|
||||
public void setLesInstruments(ArrayList<Instrument> lesInstruments) {
|
||||
this.lesInstruments = lesInstruments;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user