Application.java 1.78 KB
import java.util.Scanner;

public class Application {

 static Scanner in = new Scanner(System.in);
 public static void main(String[] argv) {

	Bibliotheque bib = new Bibliotheque();

	//Ranger des ouvrages:
	bib.add("I101",new Ouvrage("C","Kernighan"));
	bib.add("L202",new Ouvrage("Germinal","Zola"));
	bib.add("S303",new Ouvrage("Parapente","Ali Gali"));
	bib.add("I345",new Ouvrage("Java","Eckel"));
	bib.add("1",new Ouvrage("Test","E"));
	bib.add("2",new Revue("Date","Eckel",20180000,1));
	bib.add("3",new Revue("PasDate","Teckel",20180514,1));
	bib.listing();
	
    int choix=0;
    do {
    menu();
    System.out.print("votre choix? ");
    choix = in.nextInt();
    switch (choix) {
    case 1 : //emprunt
        menuEmprunt(bib);
        menuListing(bib);
        break;
    case 2 : //retour
        menuRetourner(bib);
        menuListing(bib);
        break;
        
    case 3 : //affiche
        menuListing(bib);
        break;
    case 0: // quitter
   }
  } while (choix!=0);
	//Permettre a l'utilisateur d'emprunter/retourner un ouvrage
	//en demandant son code.
	//Transformer les exceptions en message d'erreur.
	
	
	
	
 }
 
  static void menu() {
  System.out.println("\n1: Emprunter\n2: Retourner\n3: Lister\n0: quitter");
 }
        
static void menuEmprunt(Bibliotheque bib ) {
    try{
        System.out.print("\ncode? ");
        String code= in.next();

        bib.emprunter(code);
        
    }catch (Exception e){
        e.printStackTrace();
    }   
  
 }
 
 static void menuRetourner(Bibliotheque bib ) {
    try{
        
        System.out.print("\ncode? ");
        String code=in.next();
 
        bib.retourner(code);
    }catch (OuvrageInconnuException e){
        e.printStackTrace();
    }
  
 }
 
    static void menuListing(Bibliotheque bib ) {
        bib.listing();
    }
 
}