Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class main {
  4.  
  5.     /**
  6.      * @param args
  7.      */
  8.     public static void main(String[] args) {
  9.         // TODO Auto-generated method stub
  10.  
  11.        
  12.        
  13.         Scanner clavier=new Scanner(System.in);
  14.  
  15.     /*test d'affichage
  16.     {
  17.         String s="";
  18.         matrice mat=new matrice(5,5);
  19.        
  20.         s=mat.affiche();
  21.         System.out.println(s);
  22.         System.out.println("b");
  23.     }*/
  24.    
  25.     //jeux
  26.     {
  27.         matrice mat= new matrice(6,7);
  28.         joueur j1=new joueur();
  29.         joueur j2=new joueur();
  30.         mat.initialise();
  31.         String s="";
  32.         int col;
  33.         int lig;
  34.         boolean un_gagnant=false;
  35.         int tour=1;
  36.         System.out.println("joueur 1");
  37.         j1.ini_nom();
  38.         j1.choix_symbole();
  39.         System.out.println("joueur 2 ");
  40.         j2.ini_nom();
  41.         j2.choix_symbole();
  42.         while (!un_gagnant)
  43.         {
  44.             if (tour % 2== 1)
  45.             {
  46.                 System.out.println("au tour de : " + j1.nom);
  47.                 System.out.println ("entrez le numero d'une colonne entre 0 et 5 : ");
  48.                 col=clavier.nextInt();
  49.                 lig=mat.place(j1.symb, col);
  50.                 s=mat.affiche();
  51.                 System.out.println(s);
  52.                 if (mat.gagne_colonne(j1.symb, lig, col)
  53.                         || mat.gagne_ligne(j1.symb, lig, col)
  54.                         || mat.gagne_haut_droit_to_bas_gauche(j1.symb, lig, col)
  55.                         || mat.gagne_haut_gauche_bas_droit(j1.symb, lig, col))
  56.                 {
  57.                     System.out.println(j1.nom+ " a gagne au bout de "+ tour +" coups" );
  58.                     un_gagnant=true;
  59.                 }
  60.                
  61.             }
  62.             else
  63.             {
  64.                 System.out.println("au tour de : " + j2.nom);
  65.                 System.out.println ("entrez le numero d'une colonne  entre 0 et  5: ");
  66.                 col=clavier.nextInt();
  67.                 lig=mat.place(j2.symb, col);
  68.                 s=mat.affiche();
  69.                 System.out.println(s);
  70.                 if (mat.gagne_colonne(j2.symb, lig, col)
  71.                         || mat.gagne_ligne(j2.symb, lig, col)
  72.                         || mat.gagne_haut_droit_to_bas_gauche(j2.symb, lig, col)
  73.                         || mat.gagne_haut_gauche_bas_droit(j2.symb, lig, col))
  74.                 {
  75.                     System.out.println(j2.nom+ " a gagne au bout de "+ tour +" coups" );
  76.                     un_gagnant=true;
  77.                 }
  78.             }
  79.             tour++;
  80.             s="";
  81.         }
  82.        
  83.        
  84.     }
  85.    
  86.    
  87.     }
  88.    
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement