test emprunt <=3 livres
This commit is contained in:
@@ -14,6 +14,7 @@ import com.mycompany.bibliotheque.Metier.Bibliotheque;
|
||||
import com.mycompany.bibliotheque.Metier.Emprunt;
|
||||
import com.mycompany.bibliotheque.Metier.Utilisateur;
|
||||
import com.mycompany.bibliotheque.Metier.Livre;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class GestionBibliotheque {
|
||||
@@ -21,8 +22,9 @@ public class GestionBibliotheque {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int choix=0;
|
||||
Bibliotheque laBibli = new Bibliotheque();
|
||||
ArrayList<Livre> mesLivres = new ArrayList<>();
|
||||
Livre l1 = new Livre("Le secret des secrets","Dan Brown","9782709668385",true);
|
||||
Utilisateur u1 = new Utilisateur("Alice");
|
||||
//Utilisateur u1 = new Utilisateur("Alice", mesLivres.add(l1));
|
||||
|
||||
System.out.println("Bienvenue dans la bibliothèque !");
|
||||
while (choix!=4){
|
||||
|
@@ -15,9 +15,9 @@ import java.util.List;
|
||||
|
||||
public class Utilisateur {
|
||||
private String nom;
|
||||
private List<Livre> emprunts;
|
||||
private ArrayList<Livre> emprunts;
|
||||
|
||||
public Utilisateur(String nom) {
|
||||
public Utilisateur(String nom, ArrayList<Livre> mesLivres) {
|
||||
this.nom = nom;
|
||||
this.emprunts = new ArrayList<>();
|
||||
}
|
||||
@@ -30,8 +30,17 @@ public class Utilisateur {
|
||||
return emprunts;
|
||||
}
|
||||
|
||||
|
||||
// TODO: ajouter un emprunt si l'utilisateur a moins de 3 livres
|
||||
/**
|
||||
* @author Medhi
|
||||
*/
|
||||
public boolean emprunterLivre(Livre livre) {
|
||||
return false; // à compléter
|
||||
if (emprunts.size() < 3) {
|
||||
emprunts.add(livre);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user