màj pour version initialeV2

This commit is contained in:
2025-09-24 10:27:24 +02:00
parent 62092bb78b
commit 4189d05e82
6 changed files with 24 additions and 214 deletions

View File

@@ -1,33 +0,0 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package com.mycompany.bibliotheque;
/**
*
* @author dthev
*/
import java.util.Scanner;
public class Bibliotheque {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Livre l1 = new Livre("1984", 10.0);
Utilisateur u1 = new Utilisateur("Alice");
System.out.println("Bienvenue dans la bibliothèque !");
System.out.println("1. Afficher un livre");
System.out.println("2. Emprunter un livre");
System.out.println("Votre choix : ");
int choix = sc.nextInt();
if (choix == 1) {
System.out.println("Livre : " + l1.getTitre());
} else if (choix == 2) {
boolean ok = Emprunt.effectuerEmprunt(u1, l1);
System.out.println(ok ? "Emprunt réussi !" : "Échec de l'emprunt.");
}
}
}

View File

@@ -1,25 +0,0 @@
/*
* 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;
/**
*
* @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);
}
}

View File

@@ -11,35 +11,40 @@ package com.mycompany.bibliotheque;
public class Livre {
private String titre;
private double prixHT;
private boolean emprunte;
private String auteur;
private String isbn; // ISBN sous forme de chaîne
public Livre(String titre, double prixHT) {
public Livre(String titre, String auteur, String isbn) {
this.titre = titre;
this.prixHT = prixHT;
this.emprunte = false;
this.auteur = auteur;
this.isbn = isbn;
}
public String getTitre() {
return titre;
}
public double getPrixHT() {
return prixHT;
public void setTitre(String titre) {
this.titre = titre;
}
public boolean isEmprunte() {
return emprunte;
public String getAuteur() {
return auteur;
}
public void setEmprunte(boolean emprunte) {
this.emprunte = emprunte;
public void setAuteur(String auteur) {
this.auteur = auteur;
}
// TODO: calculer le prix TTC avec une TVA de 5.5%
public double getPrixTTC() {
return 0.0; // à compléter
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
}

View File

@@ -1,36 +0,0 @@
/*
* 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;
/**
*
* @author dthev
*/
import java.util.ArrayList;
import java.util.List;
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
}
}