6 Commits

13 changed files with 56 additions and 192 deletions

1
.gitignore vendored
View File

@@ -1 +0,0 @@
/target/

26
pom.xml
View File

@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId> <groupId>com.mycompany</groupId>
<artifactId>bibliotheque</artifactId> <artifactId>GestionBibliotheque</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
@@ -19,6 +19,7 @@
<version>4.13.2</version> <version>4.13.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<!-- Configuration du build --> <!-- Configuration du build -->
@@ -28,27 +29,10 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version> <version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<properties> <name>GestionBibliotheque</name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project> </project>

View File

@@ -9,9 +9,9 @@ package com.mycompany.bibliotheque.Contrôle;
* @author dthev * @author dthev
*/ */
public class LivreValide { public class LivreValide {
// 1. ISBN : exactement 13 chiffres // 1. ISBN : exactement 13 chiffres
public static boolean isValidIsbn(String isbn) { public static boolean isValidIsbn(String isbn) {
// TODO Emile: implémenter la validation // TODO: implémenter la validation
return false; return false;
} }
@@ -27,21 +27,9 @@ public class LivreValide {
return false; return false;
} }
// 4. Titre : longueur maximale 200 caractères // 4. Titre : longueur maximale 200 caractères
public static boolean isLongueurTitreValid(String titre) { public static boolean isLongueurTitreValid(String titre) {
// TODO Morgann: implémenter la validation // TODO: implémenter la validation
return false; return false;
} }
// 5. Titre : non null et au moins 2 caractères
public static boolean isContenuTitreValide(String titre) {
// TODO Steve: implémenter la validation
if (titre == null) {
return false;
}
boolean contenuValide = titre.matches(".*[a-zA-Z].*[a-zA-Z].*");
return contenuValide;
}
} }

View File

@@ -1,21 +1,19 @@
/* /*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * 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; package com.mycompany.bibliotheque;
/**
* Classe principale
* @author dthev
*/
import com.mycompany.bibliotheque.Métier.Bibliotheque; import com.mycompany.bibliotheque.Métier.Bibliotheque;
import com.mycompany.bibliotheque.Métier.Emprunt; import com.mycompany.bibliotheque.Métier.Emprunt;
import com.mycompany.bibliotheque.Métier.Utilisateur; import com.mycompany.bibliotheque.Métier.Utilisateur;
import com.mycompany.bibliotheque.Métier.Livre; import com.mycompany.bibliotheque.Métier.Livre;
import java.util.Scanner; import java.util.Scanner;
/**
*
* @author dthev
*/
public class GestionBibliotheque { public class GestionBibliotheque {
public static void main(String[] args) { public static void main(String[] args) {
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
@@ -24,13 +22,13 @@ public class GestionBibliotheque {
Livre l1 = new Livre("Le secret des secrets","Dan Brown","9782709668385",true); Livre l1 = new Livre("Le secret des secrets","Dan Brown","9782709668385",true);
Utilisateur u1 = new Utilisateur("Alice"); Utilisateur u1 = new Utilisateur("Alice");
System.out.println("Bienvenue dans la bibliothèque !"); System.out.println("Bienvenue dans la bibliothèque !");
while (choix!=4){ while (choix!=4){
System.out.println("1. Afficher un livre"); System.out.println("1. Afficher un livre");
System.out.println("2. Ajouter un livre"); System.out.println("3. Ajouter un livre");
System.out.println("3. Afficher les livres"); System.out.println("3. Afficher les livres");
System.out.println("4. Quitter"); System.out.println("4. Quitter");
System.out.print("Merci de faire votre choix : "); System.out.println("Votre choix : ");
choix = sc.nextInt(); choix = sc.nextInt();
switch (choix) { switch (choix) {
case 1 : case 1 :

View File

@@ -8,16 +8,15 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Classe métier *
* @author dthev * @author dthev
*/ */
public class Bibliotheque { public class Bibliotheque {
private List<Livre> lesLivres = new ArrayList<>(); private List<Livre> lesLivres = new ArrayList<>();
// 5. ISBN doit être unique // 5. ISBN doit être unique
public boolean addLivre(Livre b) { public boolean addLivre(Livre b) {
//ajoute b si valide et si n'existe pas - à écrire //ajoute b si valide et si n'existe pas - à écrire
lesLivres.add(b);
return false; return false;
} }

View File

@@ -4,16 +4,11 @@
*/ */
package com.mycompany.bibliotheque.Métier; package com.mycompany.bibliotheque.Métier;
import com.mycompany.bibliotheque.Métier.Utilisateur;
import com.mycompany.bibliotheque.Métier.Livre;
/** /**
* *
* @author dthev * @author dthev
*/ */
public class Emprunt { public class Emprunt {
// TODO: logique métier d'emprunt // TODO: logique métier d'emprunt
public static boolean effectuerEmprunt(Utilisateur u, Livre l) { public static boolean effectuerEmprunt(Utilisateur u, Livre l) {
if (l.isEmprunte()) { if (l.isEmprunte()) {

View File

@@ -5,14 +5,15 @@
package com.mycompany.bibliotheque.Métier; package com.mycompany.bibliotheque.Métier;
/** /**
* * Classe métier qui gère les livres
* @author dthev * @author dthev
*
*/ */
public class Livre { public class Livre {
private String titre; private String titre;
private String auteur; private String auteur;
private String isbn; // ISBN sous forme de chaîne private String isbn; // ISBN sous forme de chaîne
private Boolean emprunte; private Boolean emprunte;
public Livre(String titre, String auteur, String isbn, Boolean emprunte) { public Livre(String titre, String auteur, String isbn, Boolean emprunte) {

View File

@@ -4,17 +4,16 @@
*/ */
package com.mycompany.bibliotheque.Métier; package com.mycompany.bibliotheque.Métier;
/**
*
* @author dthev
*/
import com.mycompany.bibliotheque.Métier.Livre; import com.mycompany.bibliotheque.Métier.Livre;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
*
* @author dthev
*/
public class Utilisateur { public class Utilisateur {
private String nom; private String nom;
private List<Livre> emprunts; private List<Livre> emprunts;
public Utilisateur(String nom) { public Utilisateur(String nom) {

View File

@@ -2,9 +2,8 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
*/ */
package com.mycompany.bibliotheque; package com.mycompany.bibliotheque.Contrôle;
import com.mycompany.bibliotheque.Contrôle.LivreValide;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@@ -24,7 +23,6 @@ public class LivreValideTest {
/** /**
* Test of isValidIsbn method, of class LivreValide. * Test of isValidIsbn method, of class LivreValide.
* @author Emile
*/ */
@Test @Test
public void testIsValidIsbn() { public void testIsValidIsbn() {
@@ -39,7 +37,6 @@ public class LivreValideTest {
/** /**
* Test of isValidTitre method, of class LivreValide. * Test of isValidTitre method, of class LivreValide.
* @author Salomé/Emile
*/ */
@Test @Test
public void testIsValidTitre() { public void testIsValidTitre() {
@@ -54,7 +51,6 @@ public class LivreValideTest {
/** /**
* Test of isValidAuteur method, of class LivreValide. * Test of isValidAuteur method, of class LivreValide.
* @author Medhi/Steve
*/ */
@Test @Test
public void testIsValidAuteur() { public void testIsValidAuteur() {
@@ -69,7 +65,6 @@ public class LivreValideTest {
/** /**
* Test of isLongueurTitreValid method, of class LivreValide. * Test of isLongueurTitreValid method, of class LivreValide.
* @author Morgann
*/ */
@Test @Test
public void testIsLongueurTitreValid() { public void testIsLongueurTitreValid() {
@@ -82,29 +77,4 @@ public class LivreValideTest {
fail("The test case is a prototype."); fail("The test case is a prototype.");
} }
/**
* Test of isTitreValid method, of class LivreValide.
* @author Steve
*/
@Test
public void testIsContenuTitreValide() {
System.out.println("isTitreValid");
String titre = "";
assertFalse("Le titre ne doit pas être vide !", LivreValide.isContenuTitreValide(titre));
titre = null;
assertFalse("Le titre ne peut pas être nul !", LivreValide.isContenuTitreValide(titre));
titre = "Ti";
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "T";
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "1234";
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "Ti2";
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "*$!";
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "Ti!";
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
}
} }

View File

@@ -1,23 +0,0 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
*/
package com.mycompany.bibliotheque;
import com.mycompany.bibliotheque.Métier.Livre;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class LivreTest {
@Test
public void testCreationLivre() {
Livre b = new Livre("1984", "George Orwell", "1234567890123", false);
assertNotNull("L'objet Livre ne peut pas être nulle !", b);
assertEquals("Titre du Livre incorrect", "1984", b.getTitre());
assertEquals("Auteur du Livre incorrect", "George Orwel", b.getAuteur()); // corrigé
assertEquals("ISBN du Livre incorrect", "1234567890123", b.getIsbn());
assertFalse("Le livre n'est pas censé être emprunté", b.isEmprunte()); // si la méthode existe
}
}

View File

@@ -2,10 +2,8 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
*/ */
package com.mycompany.bibliotheque; package com.mycompany.bibliotheque.Métier;
import com.mycompany.bibliotheque.Métier.Bibliotheque;
import com.mycompany.bibliotheque.Métier.Livre;
import java.util.List; import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;

View File

@@ -0,0 +1,26 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
*/
package com.mycompany.bibliotheque.Métier;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author dthev
*/
public class LivreTest {
@Test
public void testCreationLivre() {
Livre b = new Livre("1984", "George Orwell", "1234567890123", false);
assertNotNull(b);
assertEquals("1984", b.getTitre());
assertEquals("George Orwell", b.getAuteur()); // corrigé
assertEquals("1234567890123", b.getIsbn());
assertFalse(b.isEmprunte()); // si la méthode existe
}
}

View File

@@ -1,70 +0,0 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
*/
package com.mycompany.bibliotheque;
import com.mycompany.bibliotheque.Métier.Utilisateur;
import com.mycompany.bibliotheque.Métier.Livre;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author dthev
*/
public class UtilisateurTest {
public UtilisateurTest() {
}
@Before
public void setUp() {
}
/**
* Test of getNom method, of class Utilisateur.
*/
@Test
public void testGetNom() {
System.out.println("getNom");
Utilisateur instance = null;
String expResult = "";
String result = instance.getNom();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getEmprunts method, of class Utilisateur.
*/
@Test
public void testGetEmprunts() {
System.out.println("getEmprunts");
Utilisateur instance = null;
List<Livre> expResult = null;
List<Livre> result = instance.getEmprunts();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of emprunterLivre method, of class Utilisateur.
*/
@Test
public void testEmprunterLivre() {
System.out.println("emprunterLivre");
Livre livre = null;
Utilisateur instance = null;
boolean expResult = false;
boolean result = instance.emprunterLivre(livre);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
}