0% ont trouvé ce document utile (0 vote)
15 vues4 pages

Recherche de livres par critères

Transféré par

Floot Chot
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats TXT, PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
15 vues4 pages

Recherche de livres par critères

Transféré par

Floot Chot
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats TXT, PDF, TXT ou lisez en ligne sur Scribd

package org.

example;

import [Link];
import [Link];
import [Link];

public class Rechercher {

public static int[] trie(int[] tab1, int[] tab2, int nbr_livre) {


int[] resultat = new int[nbr_livre];

for (int i = 0; i < nbr_livre; i++) {


for (int j = 0; j < nbr_livre; j++) {
if (tab1[i] == tab2[j]) {
resultat[i] = tab1[i];
break;
} else {
resultat[i] = -1;
}
}

}
return resultat;
}

public static int[] Titre(String titre, ArrayList<Livre> bibliotheque) {


int nbr_livre=[Link]();
titre = [Link]();
int compteur = 0;
/* tableau des livres ayant ce titre */
int[] tableau = new int[nbr_livre];

/*je remplie le tableau de -1 pour pourvoir identifier pus tard là ou les


livres sont recences. Pourquoi ne
pas prendre 0? juste par ce qu'identifier un livre revient à identifier sa
position dans le tableau de livres
dont les indices commencent par 0
*/

[Link](tableau, -1);

for (int i = 0; i < nbr_livre; i++) {


String temp = [Link](i).[Link]();
titre = [Link]();
if ([Link](titre)) {
tableau[compteur] = i;
++compteur;

}
}

return tableau;
}
public static int[] Auteur(String auteur, ArrayList<Livre> bibliotheque) {
auteur = [Link]();
int compteur = 0;
/* tableau des livres ayant ce auteur */
int[] tableau = new int[[Link]()];

/*je remplie le tableau de -1 pour pourvoir identifier pus tard là ou les


livres sont recences. Pourquoi ne
pas prendre 0? juste par ce qu'identifier un livre revient à identifier sa
position dans le tableau de livres
dont les indices commencent par 0
*/
[Link](tableau, -1);

for (int i = 0; i < [Link](); i++) {


String temp = [Link](i).[Link]();
auteur = [Link]();
if ([Link](auteur)) {
tableau[compteur] = i;
++compteur;

}
}

return tableau;
}

public static int[] Genre(String genre, ArrayList<Livre> bibliotheque) {


genre = [Link]();
int compteur = 0;
/* tableau des livres ayant ce genre */
int[] tableau = new int[[Link]()];

[Link](tableau, -1);

for (int i = 0; i < [Link](); i++) {


String temp = [Link](i).[Link]();
genre = [Link]();
if ([Link](genre)) {
tableau[compteur] = i;
++compteur;

}
}

return tableau;
}

public static int[] Annee(int annee, ArrayList<Livre> bibliotheque) {

int compteur = 0;
/* tableau des livres ayant ce auteur */
int[] tableau = new int[[Link]()];

[Link](tableau, -1);

for (int i = 0; i < [Link](); i++) {


if ([Link](i).annee_de_publication == annee) {
tableau[compteur] = i;
++compteur;

}
}

return tableau;
}

public static int[] TitreAuteur(String titre, String auteur, ArrayList<Livre>


bibliotheque) {
int[] tab1 = Titre(titre, bibliotheque);
int[] tab2 = Auteur(auteur, bibliotheque);
int[] trie = trie(tab1, tab2, [Link]());
return trie;
}

public static int[] TitreGenre(String titre, String genre, ArrayList<Livre>


bibliotheque) {
int[] tab1 = Titre(titre, bibliotheque);
int[] tab2 = Genre(genre, bibliotheque);
int[] resultat = trie(tab1, tab2, [Link]());
return resultat;
}

public static int[] AuteurGenre(String auteur, String genre,ArrayList<Livre>


bibliotheque) {
int[] tab1 = Auteur(auteur, bibliotheque);
int[] tab2 = Genre(genre, bibliotheque);
int[] resultat = trie(tab1, tab2, [Link]());
return resultat;
}

public static int[] AuteurAnnee(String auteur, int annee,ArrayList<Livre>


bibliotheque) {
int[] tab1 = Auteur(auteur, bibliotheque);
int[] tab2 = Annee(annee, bibliotheque);
int[] resultat = trie(tab1, tab2,[Link]());
return resultat;
}

public static int[] TitreAnnee(String titre, int annee, ArrayList<Livre>


bibliotheque) {
int[] tab1 = Titre(titre, bibliotheque);
int[] tab2 = Annee(annee, bibliotheque);
int[] resultat = trie(tab1, tab2,[Link]());
return resultat;
}

public static int[] GenreAnnee(String genre, int annee, ArrayList<Livre>


bibliotheque) {
int[] tab1 = Genre(genre, bibliotheque);
int[] tab2 = Annee(annee, bibliotheque);
int[] resultat = trie(tab1, tab2,[Link]());
return resultat;
}

public static int[] TitreAuteurAnnee(String titre, String auteur, int annee,


ArrayList<Livre> bibliotheque) {
int[] tab1 = TitreAuteur(titre, auteur, bibliotheque);
int[] tab2 = Annee(annee, bibliotheque);
int[] resultat = trie(tab1, tab2,[Link]());
return resultat;
}

public static int[] TitreAuteurGenre(String titre, String auteur, String


genre,ArrayList<Livre> bibliotheque) {
int[] tab1 = TitreAuteur(titre, auteur, bibliotheque);
int[] tab2 = Genre(genre, bibliotheque);
int[] resultat = trie(tab1, tab2,[Link]());
return resultat;
}

public static int[] AuteurAnneeGenre(String auteur, int annee, String


genre,ArrayList<Livre> bibliotheque) {
int[] tab1 = AuteurAnnee(auteur, annee, bibliotheque);
int[] tab2 = Genre(genre, bibliotheque);
int[] resultat = trie(tab1, tab2,[Link]());
return resultat;
}

public static int[] TitreAuteurAnneeGenre(String titre,String auteur, int


annee, String genre, ArrayList<Livre> bibliotheque) {
int[] tab1 = AuteurAnneeGenre(auteur, annee,genre, bibliotheque);
int[] tab2 = Titre(titre, bibliotheque);
int[] resultat = trie(tab1, tab2,[Link]());
return resultat;
}

Vous aimerez peut-être aussi