màj pour version initialeV2
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 com.mycompany.bibliotheque.Métier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dthev
|
||||
*/
|
||||
public class Bibliotheque {
|
||||
private List<Livre> lesLivres = new ArrayList<>();
|
||||
|
||||
// 5. ISBN doit être unique
|
||||
public boolean addLivre(Livre b) {
|
||||
//ajoute b si valide et si n'existe pas - à écrire
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Livre> getLesLivres() {
|
||||
return lesLivres;
|
||||
}
|
||||
|
||||
public void setLesLivres(List<Livre> lesLivres) {
|
||||
this.lesLivres = lesLivres;
|
||||
}
|
||||
|
||||
|
||||
}
|
23
src/main/java/com/mycompany/bibliotheque/Métier/Emprunt.java
Normal file
23
src/main/java/com/mycompany/bibliotheque/Métier/Emprunt.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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 com.mycompany.bibliotheque.Métier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dthev
|
||||
*/
|
||||
public class Emprunt {
|
||||
// TODO: logique métier d'emprunt
|
||||
public static boolean effectuerEmprunt(Utilisateur u, Livre l) {
|
||||
if (l.isEmprunte()) {
|
||||
return false; // déjà emprunté
|
||||
}
|
||||
if (u.getEmprunts().size() >= 3) {
|
||||
return false; // trop de livres empruntés
|
||||
}
|
||||
l.setEmprunte(true);
|
||||
return u.emprunterLivre(l);
|
||||
}
|
||||
}
|
67
src/main/java/com/mycompany/bibliotheque/Métier/Livre.java
Normal file
67
src/main/java/com/mycompany/bibliotheque/Métier/Livre.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 com.mycompany.bibliotheque.Métier;
|
||||
|
||||
/**
|
||||
* Classe métier qui gère les livres
|
||||
* @author dthev
|
||||
*
|
||||
*/
|
||||
|
||||
public class Livre {
|
||||
private String titre;
|
||||
private String auteur;
|
||||
private String isbn; // ISBN sous forme de chaîne
|
||||
private Boolean emprunte;
|
||||
|
||||
public Livre(String titre, String auteur, String isbn, Boolean emprunte) {
|
||||
this.titre = titre;
|
||||
this.auteur = auteur;
|
||||
this.isbn = isbn;
|
||||
this.emprunte = emprunte;
|
||||
}
|
||||
|
||||
//getters et setters
|
||||
public String getTitre() {
|
||||
return titre;
|
||||
}
|
||||
|
||||
public void setTitre(String titre) {
|
||||
this.titre = titre;
|
||||
}
|
||||
|
||||
public String getAuteur() {
|
||||
return auteur;
|
||||
}
|
||||
|
||||
public void setAuteur(String auteur) {
|
||||
this.auteur = auteur;
|
||||
}
|
||||
|
||||
public String getIsbn() {
|
||||
return isbn;
|
||||
}
|
||||
|
||||
public void setIsbn(String isbn) {
|
||||
this.isbn = isbn;
|
||||
}
|
||||
|
||||
public boolean isEmprunte() {
|
||||
return emprunte;
|
||||
}
|
||||
|
||||
public void setEmprunte(boolean emprunte) {
|
||||
this.emprunte = emprunte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Livre{" + "titre=" + titre + ", auteur=" + auteur + ", isbn=" + isbn + ", emprunte=" + emprunte + '}';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 com.mycompany.bibliotheque.Métier;
|
||||
|
||||
import com.mycompany.bibliotheque.Métier.Livre;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dthev
|
||||
*/
|
||||
public class Utilisateur {
|
||||
private String nom;
|
||||
private List<Livre> emprunts;
|
||||
|
||||
public Utilisateur(String nom) {
|
||||
this.nom = nom;
|
||||
this.emprunts = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public List<Livre> getEmprunts() {
|
||||
return emprunts;
|
||||
}
|
||||
|
||||
// TODO: ajouter un emprunt si l'utilisateur a moins de 3 livres
|
||||
public boolean emprunterLivre(Livre livre) {
|
||||
return false; // à compléter
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user