java d'intervalle de resultat
/**
* @author TTGamer
*/
public class Program
{
static Scanner scanne = new Scanner(System.in);
public static ArrayList<Article> articles = new ArrayList();
public static void main(String[] args)
{
do{
//searchByIntervalle
System.out.println("\n----------------------------------------\n"
+ "Bienvenue dans l'intervalle de prix\n"
+ "----------------------------------------\n");
System.out.print("Veuillez saisir un prix minimum\n> ");
int prixMin = scanne.nextInt();
System.out.println("Veuillez saisir un prix maximum\n> ");
int prixMax = scanne.nextInt();
Program.searchByIntervalle(prixMin, prixMax);
// Demmamde a l'utilisateur si il veut continuer
System.out.print("\nVoulez-vous continuer le programme ?(oui/non)\n> ");
repBoucle = scanne.next();
if (repBoucle.equals("oui"))
{
boucle = true;
}
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
} while (boucle == true)
}
// Methode in build
protected static void searchByIntervalle(int prixMin, int prixMax) {
articles.forEach((article) -> {
if (prixMin >= 0 && prixMax <= 6000) {
System.out.println("\nArticle correspondant à votre recherche :");
System.out.println(" - Id : " + article.getId());
System.out.println(" - Nom : " + article.getName());
System.out.println(" - Prix : " + article.getPrix());
System.out.println(" - Stock : " + article.getStock());
} else {
System.err.println("----------------------------------------\n"
+ "Aucun article trouvé !\n"
+ "----------------------------------------");
}
});
}
}
// class article
/**
*
* @author TTGamer
*/
public class Article {
private int id;
private String name;
private int prix;
private int stock;
public Article(int id, String name, int prix, int stock) {
this.id = id;
this.name = name;
this.prix = prix;
this.stock = stock;
}
protected int getId() {
return this.id;
}
protected void setId(int id) {
this.id = id;
}
protected String getName() {
return this.name;
}
protected void setName(String name) {
this.name = name;
}
protected int getPrix() {
return this.prix;
}
protected void setPrix(int prix) {
this.prix = prix;
}
protected int getStock() {
return this.stock;
}
protected void setStock(int stock) {
this.stock = stock;
}
}