fonction retourLivres créé

This commit is contained in:
2025-10-03 11:28:21 +02:00
parent 7970ca8df6
commit 876d092fd4
2 changed files with 21 additions and 8 deletions

View File

@@ -4,6 +4,10 @@
*/
package com.mycompany.bibliotheque.Controle;
import com.mycompany.bibliotheque.Metier.Livre;
import com.mycompany.bibliotheque.Metier.Utilisateur;
import java.util.Scanner;
/**
* Classe de contrôle de la classe Livre
* @author dthev
@@ -78,4 +82,19 @@ public class LivreValide {
return contenuValide;
}
public static boolean retourLivre(Utilisateur user){
Scanner sc = new Scanner(System.in);
int i=0;
for(Livre unLivre:user.getEmprunts()){
i++;
System.out.println(i+". "+unLivre.getTitre());
}
System.out.print("Merci de faire votre choix : ");
int choix = sc.nextInt();
Livre leLivre = user.getEmprunts().get(choix-1);
leLivre.setEmprunte(false);
user.getEmprunts().remove(leLivre);
return leLivre.isEmprunte();
}
}