Skip to content
Snippets Groups Projects
Commit c18a54f0 authored by Laurine's avatar Laurine
Browse files

3-a CLI in the main

parent 31b55cba
Branches
No related tags found
No related merge requests found
...@@ -19,5 +19,30 @@ public class App { ...@@ -19,5 +19,30 @@ public class App {
users.add(new User("Jean", "TENRIEN", 22)); users.add(new User("Jean", "TENRIEN", 22));
users.add(new User("Lara", "TATOUILLE", 24)); users.add(new User("Lara", "TATOUILLE", 24));
users.forEach(System.out::println); users.forEach(System.out::println);
int choice = -1;
while (choice != 0) {
Scanner scanner = new Scanner(System.in);
System.out.println("Hello jeune Peufien ! dans ma super CLI");
System.out.println("Que veux-tu faire ?");
System.out.println("1- Lister les utilisateurs");
System.out.println("2- Ajouter un utilisateur");
choice = parseInt(scanner.next());
switch (choice) {
case 1-> users.forEach(System.out::println);
case 2 -> {
System.out.println("Prénom de l'utilisateur");
String firstname = scanner.next();
System.out.println("Nom de l'utilisateur");
String lastname = scanner.next();
System.out.println("Age de l'utilisateur");
String age = scanner.next();
users.add(new User(firstname, lastname, Integer.valueOf(age)));
users.forEach(System.out::println);
}
case 0 -> System.exit(0);
default -> System.out.println("Mauvaise commande");
}
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment