Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.String;
- import java.util.ArrayList;
- public class Main
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in); //initialise le scanner
- // initialise des comptes bancaires
- int choix; // initialise un int
- int choix_operation; // initialise un int
- int choix_operation2; // initialise un int
- //creer les comptes clients avec constructeur
- Client marouane = new Client(1, "Marouane");//changer
- Client titon = new Client(2, "Titon");
- Client ly = new Client(3, "Ly");
- Client tassart = new Client(4, "Tassart");
- Client henriques = new Client(5, "Henriques");
- Client barrot = new Client(6, "Barrot");
- ArrayList<Client> clients = new ArrayList<Client>();
- clients.add(marouane);
- clients.add(titon);
- clients.add(ly);
- clients.add(tassart);
- clients.add(henriques);
- clients.add(barrot);
- System.out.println("Bienvenue");
- Client cl = null;
- Compte cp = null;
- Compte cp2 = null;
- Client cl_select = null;
- int selection_client;
- do
- {
- System.out.println("1. Accedez à votre Compte");
- System.out.println("2. Sortir");
- choix = sc.nextInt();
- switch (choix)
- {
- case 1:
- do
- {
- System.out.println("Entrer votre Identifiant Client ? ");
- int identification = sc.nextInt();
- for (Client c: clients) //for each: on parcourt la liste clients
- {
- if (c.get_id() == identification) // on compare chaque id client à l'id demandé
- {
- cl = c; // si id correspond alors cl = c
- break; // sortie du for each
- }
- }
- } while (cl == null); // assure que l'utilisateur rentre un bon id
- System.out.println("Bonjour Monsieur/Madame " + cl.get_nom());
- cl.print_compte();
- do
- {
- System.out.println("1. Creer Compte");
- System.out.println("2. Selectionner Compte");
- choix_operation = sc.nextInt();
- switch (choix_operation)
- {
- case 1: cl.add_compte();
- break;
- case 2: cl.print_compte();
- do
- {
- System.out.println("choisissez compte");
- int selection = sc.nextInt();
- cp = cl.select_compte(selection);
- }while (cp == null);
- do
- {
- System.out.println("Choisissez une opération !");
- System.out.println("1. Retrait");
- System.out.println("2. Depot");
- System.out.println("3. Virement");
- System.out.println("4. Consulter Compte");
- System.out.println("5. Retour");
- choix_operation2 = sc.nextInt();
- switch(choix_operation2)
- {
- case 1: cp.retrait();
- break;
- case 2: cp.depot();
- break;
- case 3:
- {
- do
- {
- System.out.println("Selectionner un client");
- System.out.println("1. Marouane");
- System.out.println("2. Titon");
- System.out.println("3. Retour");
- //System.out.println("3. Ly");
- //System.out.println("4. Tassart");
- //System.out.println("5. Henriques");
- //System.out.println("6. Barrot");
- selection_client = sc.nextInt();
- switch (selection_client)
- {
- case 1:
- {
- for (Client c: clients) //for each: on parcourt la liste clients
- {
- if (c.get_id() == 1) // on compare chaque id client à l'id demandé
- {
- cl_select = c; // si id correspond alors cl = c
- break; // sortie du for each
- }
- }
- cl_select.print_compte();
- do
- {
- System.out.println("choisissez compte");
- int selection2 = sc.nextInt();
- cp2 = cl_select.select_compte(selection2);
- }while (cp2 == null);
- System.out.println("montant virement ?");
- float virement = sc.nextFloat();
- cp.virement(cp2, virement);
- break;
- }
- case 2:
- {
- for (Client c: clients) //for each: on parcourt la liste clients
- {
- if (c.get_id() == 2) // on compare chaque id client à l'id demandé
- {
- cl_select = c; // si id correspond alors cl = c
- break; // sortie du for each
- }
- }
- cl_select.print_compte();
- do
- {
- System.out.println("choisissez compte");
- int selection2 = sc.nextInt();
- cp2 = cl_select.select_compte(selection2);
- }while (cp2 == null);
- System.out.println("montant virement ?");
- float virement = sc.nextFloat();
- cp.virement(cp2, virement);
- break;
- }
- }
- }while(selection_client != 3);
- break;
- }
- case 4: System.out.println("Votre solde est de " + cp.get_solde() + "euro "); //affiche le solde du compte en faisant appel a la fonction get_solde
- break;
- }
- }while(choix_operation2 != 5);
- break;
- }
- }while(choix_operation != 2);
- break;
- case 2: System.out.println("A bientot !");
- break;
- }
- }while(choix != 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement