Compare commits
7 Commits
c762aac862
...
dev.pomika
Author | SHA1 | Date | |
---|---|---|---|
876d092fd4 | |||
7970ca8df6 | |||
d0db3d84a3 | |||
6e988ca75a | |||
906f075a95 | |||
09cf3836c2 | |||
19d2e618c3 |
@@ -2,7 +2,11 @@
|
||||
* 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.Contrôle;
|
||||
package com.mycompany.bibliotheque.Controle;
|
||||
|
||||
import com.mycompany.bibliotheque.Metier.Livre;
|
||||
import com.mycompany.bibliotheque.Metier.Utilisateur;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Classe de contrôle de la classe Livre
|
||||
@@ -47,14 +51,24 @@ public class LivreValide {
|
||||
|
||||
// 3. Auteur : non vide et pas de chiffres ou caractères spéciaux
|
||||
public static boolean isValidAuteur(String auteur) {
|
||||
// TODO: implémenter la validation
|
||||
//verification que auteur n'est pas vide ou null
|
||||
if (auteur == null || auteur.isBlank()) {
|
||||
return false;
|
||||
}
|
||||
//ajout d'un pattern pour avoir uniquement des minuscules/majuscules
|
||||
String pattern = "^[a-zA-Z]+$";
|
||||
//verification boolean que le nom d'auteur corresponde au patterne
|
||||
return auteur.matches(pattern);
|
||||
}
|
||||
|
||||
// 4. Titre : longueur maximale 200 caractères
|
||||
public static boolean isLongueurTitreValid(String titre) {
|
||||
// TODO Morgann: implémenter la validation
|
||||
return false;
|
||||
boolean valide = false;
|
||||
if(titre.length()<=200 && titre != "" && titre != null){
|
||||
valide = true;
|
||||
}
|
||||
return valide;
|
||||
}
|
||||
|
||||
// 5. Titre : non null et au moins 2 caractères
|
||||
@@ -68,4 +82,19 @@ public class LivreValide {
|
||||
|
||||
return contenuValide;
|
||||
}
|
||||
public static boolean retourLivre(Utilisateur user){
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int i=0;
|
||||
for(Livre unLivre:user.getEmprunts()){
|
||||
i++;
|
||||
System.out.println(i+". "+unLivre.getTitre());
|
||||
}
|
||||
System.out.print("Merci de faire votre choix : ");
|
||||
int choix = sc.nextInt();
|
||||
Livre leLivre = user.getEmprunts().get(choix-1);
|
||||
|
||||
leLivre.setEmprunte(false);
|
||||
user.getEmprunts().remove(leLivre);
|
||||
return leLivre.isEmprunte();
|
||||
}
|
||||
}
|
@@ -10,10 +10,10 @@ package com.mycompany.bibliotheque;
|
||||
*/
|
||||
|
||||
|
||||
import com.mycompany.bibliotheque.Métier.Bibliotheque;
|
||||
import com.mycompany.bibliotheque.Métier.Emprunt;
|
||||
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
||||
import com.mycompany.bibliotheque.Métier.Livre;
|
||||
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.Scanner;
|
||||
|
||||
public class GestionBibliotheque {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* 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;
|
||||
package com.mycompany.bibliotheque.Metier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@@ -2,10 +2,10 @@
|
||||
* 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;
|
||||
package com.mycompany.bibliotheque.Metier;
|
||||
|
||||
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
||||
import com.mycompany.bibliotheque.Métier.Livre;
|
||||
import com.mycompany.bibliotheque.Metier.Utilisateur;
|
||||
import com.mycompany.bibliotheque.Metier.Livre;
|
||||
|
||||
/**
|
||||
*
|
@@ -2,7 +2,7 @@
|
||||
* 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;
|
||||
package com.mycompany.bibliotheque.Metier;
|
||||
|
||||
/**
|
||||
*
|
@@ -2,14 +2,14 @@
|
||||
* 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;
|
||||
package com.mycompany.bibliotheque.Metier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dthev
|
||||
*/
|
||||
|
||||
import com.mycompany.bibliotheque.Métier.Livre;
|
||||
import com.mycompany.bibliotheque.Metier.Livre;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
package com.mycompany.bibliotheque;
|
||||
|
||||
import com.mycompany.bibliotheque.Métier.Bibliotheque;
|
||||
import com.mycompany.bibliotheque.Métier.Livre;
|
||||
import com.mycompany.bibliotheque.Metier.Bibliotheque;
|
||||
import com.mycompany.bibliotheque.Metier.Livre;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.mycompany.bibliotheque;
|
||||
|
||||
import com.mycompany.bibliotheque.Métier.Livre;
|
||||
import com.mycompany.bibliotheque.Metier.Livre;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -16,7 +16,7 @@ public void testCreationLivre() {
|
||||
|
||||
assertNotNull(b);
|
||||
assertEquals("1984", b.getTitre());
|
||||
assertEquals("George Orwel", b.getAuteur()); // corrigé
|
||||
assertEquals("George Orwell", b.getAuteur()); // corrigé
|
||||
assertEquals("1234567890123", b.getIsbn());
|
||||
assertFalse(b.isEmprunte()); // si la méthode existe
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.mycompany.bibliotheque;
|
||||
|
||||
import com.mycompany.bibliotheque.Contrôle.LivreValide;
|
||||
import com.mycompany.bibliotheque.Controle.LivreValide;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -118,12 +118,24 @@ public class LivreValideTest {
|
||||
@Test
|
||||
public void testIsValidAuteur() {
|
||||
System.out.println("isValidAuteur");
|
||||
String auteur = "";
|
||||
boolean expResult = false;
|
||||
boolean result = LivreValide.isValidAuteur(auteur);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
|
||||
//Verification Bonne
|
||||
String auteurTrue = "George";
|
||||
boolean expResult = true;
|
||||
boolean result = LivreValide.isValidAuteur(auteurTrue);
|
||||
assertEquals("Cas d'utilisation prévu",expResult, result);
|
||||
|
||||
//Verification avec un nombre
|
||||
String auteurFalse1 = "George4";
|
||||
boolean expResult1 = false;
|
||||
boolean result1 = LivreValide.isValidAuteur(auteurFalse1);
|
||||
assertEquals("Non valide car un nombre est présent", expResult1,result1);
|
||||
|
||||
//Verification avec des caractères spéciaux
|
||||
String auteurFalse2 = "George_";
|
||||
boolean expResult2 = false;
|
||||
boolean result2 = LivreValide.isValidAuteur(auteurFalse2);
|
||||
assertEquals("Non valide car des caractères spéciaux sont présent", expResult2,result2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,21 +145,33 @@ public class LivreValideTest {
|
||||
@Test
|
||||
public void testIsLongueurTitreValid() {
|
||||
System.out.println("isLongueurTitreValid");
|
||||
String titre = "";
|
||||
boolean expResult = false;
|
||||
boolean result = LivreValide.isLongueurTitreValid(titre);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
|
||||
//test 1 : aucune valeur saisie
|
||||
System.out.println("Test avec aucune valeur saisie");
|
||||
String titre1 = "";
|
||||
boolean expResult1 = false;
|
||||
boolean result1 = LivreValide.isLongueurTitreValid(titre1);
|
||||
assertEquals(expResult1, result1);
|
||||
System.out.println("Titre invalide. Aucune valeur n'a été saisie\n");
|
||||
|
||||
//test 2 : titre inférieur à 200
|
||||
System.out.println("Test avec valeur saisie OK");
|
||||
String titre2 = "Hadal Blacksite bestiary";
|
||||
boolean expResult2 = true;
|
||||
boolean result2 = LivreValide.isLongueurTitreValid(titre2);
|
||||
assertEquals(expResult2, result2);
|
||||
System.out.println("Titre valide. Le titre a moins de 200 caractères\n");
|
||||
|
||||
System.out.println("Test avec un titre avec plus de 200 caractères");
|
||||
String titre3 = "YOU !! You could've had everything you ever wanted... Everything I ever wanted... And you still went out of your way to take everything I had left in the process. You entitled brat. You expect me to sit idly by and keep smiling, As if nothing ever happened? Oh, I'm smiling alright... GRINNING ear to ear. Don't even start with that 'following orders' schlock. You knew what you were doing all too well. Sure took your sweet time. Enjoyed every last second of it? Good. *Chuckles* EXCELLENT, even! I'll merely return the favor. And you bet, I'll be enjoying, every last moment, of THIS!!! THE BEST PART!? I get to do this, over, and over, again. You'll come back, I'll know, and I'll be waiting... You have no one to blame but yourself. You're in a hell of your own making... And you're NEVER GETTING OUT!!! *grrgh* WHAT!!! WHAT IS IT THIS TIME!?!?";
|
||||
boolean expResult3 = false;
|
||||
boolean result3 = LivreValide.isLongueurTitreValid(titre3);
|
||||
assertEquals(expResult3, result3);
|
||||
System.out.println("Titre invalide. Titre trop long\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsContenuTitreValid() {
|
||||
System.out.println("isLongueurTitreValid");
|
||||
String titre = "";
|
||||
boolean expResult = false;
|
||||
boolean result = LivreValide.isLongueurTitreValid(titre);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of isTitreValid method, of class LivreValide.
|
||||
* @author Steve
|
||||
|
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
package com.mycompany.bibliotheque;
|
||||
|
||||
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
||||
import com.mycompany.bibliotheque.Métier.Livre;
|
||||
import com.mycompany.bibliotheque.Metier.Utilisateur;
|
||||
import com.mycompany.bibliotheque.Metier.Livre;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
Reference in New Issue
Block a user