1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
import java.util.Hashtable;
public class ServiceBiblio {
private Hashtable biblio;
public ServiceCatalogue(){
biblio=new Hashtable();
biblio.put("java","Sun Microsystem");
biblio.put("Langage C","Borland");
}
//Ajout de nouveau livre
public void ajouterLivre(String titre,String auteur){
if(titre==null){
throw new IllegalArgumentException(" Le titre et le nom de l'auteur doivent etre renseignés");
}
biblio.put(titre.hashCode(), auteur);
}
//Recherche de livre
public String TrouverAuteur(String titre){
if(titre==null){
throw new IllegalArgumentException(" Le titre doit etre renseigné");
}
//Retourner l'auteur correspondant à la clé du titre
return (String) biblio.get(titre.Hashcode);
}
} |
Partager