Advertisement
MonsterScripter

Tableau_Grille

Nov 19th, 2019
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.30 KB | None | 0 0
  1. import iut.algo.Clavier;
  2.  
  3. /** Class La grille
  4.   * @author Monster
  5.   * date : 18/11/2019
  6.   */
  7.  
  8. public class TP6_exercice8V2
  9. {
  10.     static String tabEnChaine (char[][] tab)
  11.     {
  12.         String retour = "   ";
  13.         for(int i=0; i<tab[0].length; i++)
  14.         {
  15.             retour = retour + "  " + i + " ";
  16.         }
  17.         retour = retour + "\n   +";
  18.        
  19.         for(int i=0; i<tab[0].length; i++)
  20.         {
  21.             retour = retour + "---+";
  22.         }
  23.         retour = retour + "\n";
  24.         for(int i=0; i<tab.length; i++)
  25.         {
  26.             retour = retour + i + " ";
  27.             if(i<10) retour += " ";
  28.             retour = retour + "| ";
  29.             for(int j=0; j<tab[i].length; j++)
  30.             {
  31.                 retour = retour + tab[i][j] + " | ";
  32.             }
  33.             retour = retour + "\n   +";
  34.             for(int j=0; j<tab[i].length; j++)
  35.             {
  36.                 retour = retour + "---+";
  37.             }
  38.             retour = retour + "\n";
  39.         }
  40.        
  41.         return retour;
  42.     }
  43.  
  44.     public static void main(String[] a)
  45.     {
  46.         /*----------------------*/
  47.         /*  Données             */
  48.         /*----------------------*/
  49.  
  50.         char[][]  tabCara1;
  51.         char[][]  tabCara2;
  52.         char[][]  tabCara3;
  53.  
  54.         int [][] tabTest;    
  55.         /*----------------------*/
  56.         /*  Instructions        */
  57.         /*----------------------*/
  58.         tabTest = new int[8][8];
  59.         // Initialisation des deux tableaux.
  60.         tabCara1 = new char[][] { { 'T','C','F','Q','K','F','C','T' },
  61.                                                             { 'P','P','P','P','P','P','P','P' },
  62.                                                             { ' ',' ',' ',' ',' ',' ',' ',' ' },
  63.                                                             { ' ',' ',' ',' ',' ',' ',' ',' ' },
  64.                                                             { ' ',' ',' ',' ',' ',' ',' ',' ' },
  65.                                                             { ' ',' ',' ',' ',' ',' ',' ',' ' },
  66.                                                             { 'p','p','p','p','p','p','p','p' },
  67.                                                             { 't','c','f','q','k','f','c','t' }  };
  68.  
  69.         tabCara2 = new char[][] { { 'A', 'B', 'C', 'D' },
  70.                                                             { 'E', 'F', 'G', 'H' } };
  71.  
  72.  
  73.         tabCara3 = new char[][] { { 'M', 'M', 'M', 'M', 'M', 'M',  'M', 'M', 'M' },
  74.                                                             { 'M', ' ', ' ', 'M', ' ', ' ',  ' ', 'M', ' ' },
  75.                                                             { 'M', ' ', 'M', 'M', 'M', 'M',  ' ', ' ', ' ' },
  76.                                                             { 'M', ' ', 'M', 'M', 'M', 'M',  'M', 'M', ' ' },
  77.                                                             { 'M', ' ', ' ', ' ', 'M', 'M',  ' ', ' ', ' ' },
  78.                                                             { 'M', 'M', 'M', ' ', 'M', 'M',  ' ', 'M', 'M' },
  79.                                                             { 'M', ' ', 'M', ' ', 'M', 'M',  ' ', 'M', 'M' },
  80.                                                             { 'M', 'M', ' ', ' ', 'M', 'M',  ' ', ' ', ' ' },
  81.                                                             { 'M', ' ', ' ', 'M', 'M', 'M',  ' ', 'M', ' ' },
  82.                                                             { 'M', ' ', 'M', 'M', 'M', 'M',  ' ', 'M', ' ' },
  83.                                                             { 'M', ' ', ' ', ' ', ' ', 'M',  ' ', 'M', ' ' },
  84.                                                             { 'M', ' ', 'M', 'M', ' ', 'M',  ' ', 'M', ' ' },
  85.                                                             { 'M', ' ', ' ', ' ', ' ', ' ',  ' ', 'M', ' ' },
  86.                                                             { 'M', 'M', 'M', 'M', 'M', 'M',  'M', 'M', ' ' }  };
  87.  
  88.         // ETAPE 1 Affichage de tabCara1 à l'aide de tabEnChaine de VisuGrille    
  89.         System.out.println(tabEnChaine(tabCara1));
  90.         //System.out.println();
  91.        
  92.    
  93.  
  94.         // ETAPE 2 Affichage de tabCara2 à l'aide de tabEnChaine de VisuGrille
  95.         System.out.println(tabEnChaine(tabCara2));
  96.         //System.out.println();
  97.  
  98.  
  99.         // ETAPE 3 Affichage de tabCara3 à l'aide de tabEnChaine de VisuGrille
  100.         //System.out.println(tabEnChaine(tabCara3));
  101.         //System.out.println();
  102.  
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement