Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.65 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.String;
  3. import java.util.ArrayList;
  4.  
  5. public class Main
  6. {
  7.  
  8.     public static void main(String[] args)
  9.     {
  10.          Scanner sc = new Scanner(System.in); //initialise le scanner
  11.  
  12.          
  13.          // initialise des comptes bancaires
  14.          int choix; // initialise un int
  15.          int choix_operation; // initialise un int
  16.          int choix_operation2; // initialise un int
  17.  
  18.          
  19.          
  20.          //creer les comptes clients avec constructeur
  21.          Client marouane = new Client(1, "Marouane");//changer
  22.          Client titon = new Client(2, "Titon");
  23.          Client ly = new Client(3, "Ly");
  24.          Client tassart = new Client(4, "Tassart");
  25.          Client henriques = new Client(5, "Henriques");
  26.          Client barrot = new Client(6, "Barrot");
  27.          
  28.          ArrayList<Client> clients = new ArrayList<Client>();
  29.          clients.add(marouane);
  30.          clients.add(titon);
  31.          clients.add(ly);
  32.          clients.add(tassart);
  33.          clients.add(henriques);
  34.          clients.add(barrot);
  35.          
  36.          
  37.          System.out.println("Bienvenue");
  38.          
  39.          Client cl = null;
  40.          Compte cp = null;
  41.          Compte cp2 = null;
  42.          Client cl_select = null;
  43.          int selection_client;
  44.          
  45.          do
  46.          {
  47.             System.out.println("1. Accedez à votre Compte");
  48.             System.out.println("2. Sortir");
  49.             choix = sc.nextInt();
  50.             switch (choix)
  51.             {
  52.             case 1:
  53.                 do
  54.                 {
  55.                      System.out.println("Entrer votre Identifiant Client ? ");  
  56.                      int identification = sc.nextInt();
  57.                      for (Client c: clients) //for each: on parcourt la liste clients
  58.                      {
  59.                          if (c.get_id() == identification) // on compare chaque id client à l'id demandé
  60.                          {
  61.                              cl = c; // si id correspond alors cl = c
  62.                              break; // sortie du for each
  63.                          }
  64.                      }
  65.                 } while (cl == null); // assure que l'utilisateur rentre un bon id
  66.                  
  67.                 System.out.println("Bonjour Monsieur/Madame " + cl.get_nom());
  68.                 cl.print_compte();
  69.                
  70.                 do
  71.                 {
  72.                     System.out.println("1. Creer Compte");
  73.                     System.out.println("2. Selectionner Compte");
  74.                     choix_operation = sc.nextInt();
  75.                    
  76.                     switch (choix_operation)
  77.                     {
  78.                     case 1: cl.add_compte();
  79.                     break;
  80.                    
  81.                     case 2: cl.print_compte();
  82.                     do
  83.                     {
  84.                         System.out.println("choisissez compte");
  85.                         int selection = sc.nextInt();
  86.                         cp = cl.select_compte(selection);
  87.                     }while (cp == null);
  88.                    
  89.                     do
  90.                     {
  91.                         System.out.println("Choisissez une opération !");
  92.                         System.out.println("1. Retrait");
  93.                         System.out.println("2. Depot");
  94.                         System.out.println("3. Virement");
  95.                         System.out.println("4. Consulter Compte");
  96.                         System.out.println("5. Retour");
  97.                        
  98.                         choix_operation2 = sc.nextInt();
  99.                        
  100.                         switch(choix_operation2)
  101.                         {
  102.                         case 1: cp.retrait();
  103.                         break;
  104.                        
  105.                         case 2: cp.depot();
  106.                         break;
  107.                        
  108.                         case 3:
  109.                         {
  110.                         do
  111.                         {
  112.                         System.out.println("Selectionner un client");
  113.                         System.out.println("1. Marouane");
  114.                         System.out.println("2. Titon");
  115.                         System.out.println("3. Retour");
  116.                         //System.out.println("3. Ly");
  117.                         //System.out.println("4. Tassart");
  118.                         //System.out.println("5. Henriques");
  119.                         //System.out.println("6. Barrot");
  120.                         selection_client = sc.nextInt();
  121.                         switch (selection_client)
  122.                         {
  123.                             case 1:  
  124.                             {
  125.                                 for (Client c: clients) //for each: on parcourt la liste clients
  126.                                  {
  127.                                      if (c.get_id() == 1) // on compare chaque id client à l'id demandé
  128.                                      {
  129.                                          cl_select = c; // si id correspond alors cl = c
  130.                                          break; // sortie du for each
  131.                                      }
  132.                                  }
  133.                                 cl_select.print_compte();
  134.                                 do
  135.                                 {
  136.                                     System.out.println("choisissez compte");
  137.                                     int selection2 = sc.nextInt();
  138.                                     cp2 = cl_select.select_compte(selection2);
  139.                                 }while (cp2 == null);
  140.                                 System.out.println("montant virement ?");
  141.                                 float virement = sc.nextFloat();
  142.                                 cp.virement(cp2, virement);
  143.                                 break;
  144.                             }
  145.                             case 2:  
  146.                             {
  147.                                 for (Client c: clients) //for each: on parcourt la liste clients
  148.                                  {
  149.                                      if (c.get_id() == 2) // on compare chaque id client à l'id demandé
  150.                                      {
  151.                                          cl_select = c; // si id correspond alors cl = c
  152.                                          break; // sortie du for each
  153.                                      }
  154.                                  }
  155.                                 cl_select.print_compte();
  156.                                 do
  157.                                 {
  158.                                     System.out.println("choisissez compte");
  159.                                     int selection2 = sc.nextInt();
  160.                                     cp2 = cl_select.select_compte(selection2);
  161.                                 }while (cp2 == null);
  162.                                 System.out.println("montant virement ?");
  163.                                 float virement = sc.nextFloat();
  164.                                 cp.virement(cp2, virement);
  165.                                 break;
  166.        
  167.                             }
  168.                         }
  169.                        
  170.                         }while(selection_client != 3);
  171.                         break;
  172.                         }
  173.                        
  174.                         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
  175.                         break;
  176.                         }
  177.                     }while(choix_operation2 != 5);
  178.                     break;
  179.                     }
  180.                 }while(choix_operation != 2);
  181.                        
  182.            
  183.             break;
  184.            
  185.            
  186.             case 2: System.out.println("A bientot !");
  187.             break;
  188.                
  189.             }
  190.          }while(choix != 2);
  191.          
  192.     }
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement