49443da5
Vincent Benoist
tp avance
|
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
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();
}
}
|