Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class main {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner clavier=new Scanner(System.in);
- /*test d'affichage
- {
- String s="";
- matrice mat=new matrice(5,5);
- s=mat.affiche();
- System.out.println(s);
- System.out.println("b");
- }*/
- //jeux
- {
- matrice mat= new matrice(6,7);
- joueur j1=new joueur();
- joueur j2=new joueur();
- mat.initialise();
- String s="";
- int col;
- int lig;
- boolean un_gagnant=false;
- int tour=1;
- System.out.println("joueur 1");
- j1.ini_nom();
- j1.choix_symbole();
- System.out.println("joueur 2 ");
- j2.ini_nom();
- j2.choix_symbole();
- while (!un_gagnant)
- {
- if (tour % 2== 1)
- {
- System.out.println("au tour de : " + j1.nom);
- System.out.println ("entrez le numero d'une colonne entre 0 et 5 : ");
- col=clavier.nextInt();
- lig=mat.place(j1.symb, col);
- s=mat.affiche();
- System.out.println(s);
- if (mat.gagne_colonne(j1.symb, lig, col)
- || mat.gagne_ligne(j1.symb, lig, col)
- || mat.gagne_haut_droit_to_bas_gauche(j1.symb, lig, col)
- || mat.gagne_haut_gauche_bas_droit(j1.symb, lig, col))
- {
- System.out.println(j1.nom+ " a gagne au bout de "+ tour +" coups" );
- un_gagnant=true;
- }
- }
- else
- {
- System.out.println("au tour de : " + j2.nom);
- System.out.println ("entrez le numero d'une colonne entre 0 et 5: ");
- col=clavier.nextInt();
- lig=mat.place(j2.symb, col);
- s=mat.affiche();
- System.out.println(s);
- if (mat.gagne_colonne(j2.symb, lig, col)
- || mat.gagne_ligne(j2.symb, lig, col)
- || mat.gagne_haut_droit_to_bas_gauche(j2.symb, lig, col)
- || mat.gagne_haut_gauche_bas_droit(j2.symb, lig, col))
- {
- System.out.println(j2.nom+ " a gagne au bout de "+ tour +" coups" );
- un_gagnant=true;
- }
- }
- tour++;
- s="";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement