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
| import java.util.Scanner;
public class Test {
public Test() {
// TODO Auto-generated constructor stub
super();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Bibliotheque bibli = new Bibliotheque();
Livre liv = new Livre(null, null, null);
Scanner sc = new Scanner(System.in);
boolean bool = true;
/*bibli.Ajouter(liv);
bibli.Afficher();*/
// Demander au user les actions à réaliser
String menu = "*** Menu *** \n"+
" Pour effectuer une action, saisissez le choix correspondant : \n" +
" Ajouter un livre 1\n"+
" Afficher la Biblothèque 2\n"+
" Quitter le programme 3\n";
// Afficher choix user
while(bool){
System.out.print("\n" +menu);
// Action à réaliser
String choix = sc.next();
try{
// Tests des choix
switch(choix){
case "1":
bibli.Ajouter(liv);
break;
case "2":
bibli.Afficher();
break;
case "3":
bool = false;
break;
default:
System.out.println("Veuillez saisir un choix valide ");
break;
}
}
catch(NumberFormatException e){
System.out.println("Ce n'est pas un nombre");
}
}
sc.close();
}
} |
Partager