Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
d8ec5254df | |||
bc740d970e | |||
|
22bce1d53b | ||
6ec5d152eb | |||
|
f1571ced27 | ||
ca3338fe1a | |||
|
0eac6c497d | ||
|
980fc1cc7c | ||
bec1ca9f04 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target/
|
20
pom.xml
20
pom.xml
@@ -30,7 +30,25 @@
|
|||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.1.2</version>
|
||||||
</plugin>
|
</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>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -11,7 +11,7 @@ package com.mycompany.bibliotheque.Contrôle;
|
|||||||
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: implémenter la validation
|
// TODO Emile: implémenter la validation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,13 +29,19 @@ public class LivreValide {
|
|||||||
|
|
||||||
// 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: implémenter la validation
|
// TODO Morgann: implémenter la validation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Titre : non null et au moins 2 caractères
|
// 5. Titre : non null et au moins 2 caractères
|
||||||
public static boolean isContenuTitreValide(String titre) {
|
public static boolean isContenuTitreValide(String titre) {
|
||||||
// TODO: implémenter la validation
|
// TODO Steve: implémenter la validation
|
||||||
|
if (titre == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean contenuValide = titre.matches(".*[a-zA-Z].*[a-zA-Z].*");
|
||||||
|
|
||||||
|
return contenuValide;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,13 +24,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("2. 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.println("Votre choix : ");
|
System.out.print("Merci de faire votre choix : ");
|
||||||
choix = sc.nextInt();
|
choix = sc.nextInt();
|
||||||
switch (choix) {
|
switch (choix) {
|
||||||
case 1 :
|
case 1 :
|
||||||
|
@@ -8,15 +8,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe métier
|
* 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);
|
lesLivres.add(b);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ package com.mycompany.bibliotheque.Métier;
|
|||||||
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) {
|
||||||
|
@@ -14,10 +14,10 @@ public class LivreTest {
|
|||||||
public void testCreationLivre() {
|
public void testCreationLivre() {
|
||||||
Livre b = new Livre("1984", "George Orwell", "1234567890123", false);
|
Livre b = new Livre("1984", "George Orwell", "1234567890123", false);
|
||||||
|
|
||||||
assertNotNull(b);
|
assertNotNull("L'objet Livre ne peut pas être nulle !", b);
|
||||||
assertEquals("1984", b.getTitre());
|
assertEquals("Titre du Livre incorrect", "1984", b.getTitre());
|
||||||
assertEquals("George Orwel", b.getAuteur()); // corrigé
|
assertEquals("Auteur du Livre incorrect", "George Orwel", b.getAuteur()); // corrigé
|
||||||
assertEquals("1234567890123", b.getIsbn());
|
assertEquals("ISBN du Livre incorrect", "1234567890123", b.getIsbn());
|
||||||
assertFalse(b.isEmprunte()); // si la méthode existe
|
assertFalse("Le livre n'est pas censé être emprunté", b.isEmprunte()); // si la méthode existe
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -24,6 +24,7 @@ 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() {
|
||||||
@@ -38,6 +39,7 @@ 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() {
|
||||||
@@ -52,6 +54,7 @@ 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() {
|
||||||
@@ -66,6 +69,7 @@ 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() {
|
||||||
@@ -78,4 +82,29 @@ 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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user