Advertisement
AnoTest

newGrilleJava

Dec 7th, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.93 KB | None | 0 0
  1. //Made by Samir
  2.  
  3.     @Override
  4.     public void mouseClicked(MouseEvent e) {
  5.         Graphics g = getGraphics();
  6.         g.setColor(Color.BLUE);
  7.         int[] Test = {50, 100, 150, 200, 250};
  8.         int x = e.getX();
  9.         int y = e.getY();
  10.  
  11.         if(x >= 50 &&  x<= 100 && y<= 100) {
  12.             joueur++;
  13.             if(joueur % 2 == 0)
  14.             {
  15.                 g.drawOval(50,50,50,50);
  16.             }
  17.             else
  18.             {
  19.                 System.out.println("Entered number is an odd number");
  20.                 g.drawLine(50,50, 100,100);
  21.                 g.drawLine(100,50, 50,100);
  22.             }
  23.         }
  24.         else if(x >=100 && x<=150 && y<=100) {
  25.             joueur++;
  26.             if(joueur % 2 == 0)
  27.             {
  28.                 g.drawOval(100,50,50,50);
  29.             }
  30.             else
  31.             {
  32.                 g.drawLine(100,50, 150,100);
  33.                 g.drawLine(150,50, 100,100);
  34.                 System.out.println("Entered number is an odd number");
  35.             }
  36.         }
  37.         else if(x >=150 && x<=200 && y<=100) {
  38.             joueur++;
  39.             System.out.println("avant dernier");
  40.             if(joueur % 2 == 0)
  41.             {
  42.                 g.drawOval(150,50,50,50);
  43.             }
  44.             else
  45.             {
  46.                 g.drawLine(150,50, 200,100);
  47.                 g.drawLine(200,50, 150,100);
  48.             }
  49.         }
  50.         else if(x >=200 && x<=250 && y<=100) {
  51.             joueur++;
  52.             if(joueur % 2 == 0)
  53.             {
  54.                 g.drawOval(200,50,50,50);
  55.             }
  56.             else
  57.             {
  58.                 g.drawLine(200,50, 250,100);
  59.                 g.drawLine(250,50, 200,100);
  60.             }
  61.  
  62.         }
  63.         else if(x >=250 && x<=300 && y<=100) {
  64.             joueur++;
  65.             System.out.println("dernier");
  66.             if(joueur % 2 == 0)
  67.             {
  68.                 g.drawOval(250,50,50,50);
  69.             }
  70.             else
  71.             {
  72.                 g.drawLine(250,50, 300,100);
  73.                 g.drawLine(300,50, 250,100);
  74.             }
  75.         }
  76.         //2eme Ligne
  77.         else if(x >=50 && x<=100 && y<=150) {
  78.             joueur++;
  79.             if(joueur % 2 == 0)
  80.             {
  81.                 System.out.println("pair");
  82.                 System.out.println("dernier cases");
  83.                 g.drawOval(50,100,50,50);
  84.             }
  85.             else
  86.             {
  87.                 System.out.println("impaire");
  88.                 System.out.println("dernier cases");
  89.  
  90.                 g.drawLine(50,100, 100,150);
  91.                 g.drawLine(100,100, 50,150);
  92.             }
  93.  
  94.         }
  95.         else if(x >=100 && x<=150 && y<=150) {
  96.             //2 eme cases
  97.             joueur++;
  98.             if(joueur % 2 == 0)
  99.             {
  100.                 g.drawOval(100,100,50,50);
  101.             }
  102.             else
  103.             {
  104.                 g.drawLine(100,100, 150,150);
  105.                 g.drawLine(150,100, 100,150);
  106.             }
  107.         }
  108.         else if(x >=150 && x<=200 && y<=150) {
  109.             //3 em case /2 eme ligne
  110.             joueur++;
  111.             if(joueur % 2 == 0)
  112.             {
  113.                 g.drawOval(150,100,50,50);
  114.             }
  115.             else
  116.             {
  117.                 g.drawLine(150,100, 200,150);
  118.                 g.drawLine(200,100, 150,150);
  119.             }
  120.         } else if(x >=200 && x<=250 && y<=150) {
  121.             joueur++;
  122.             if(joueur % 2 == 0)
  123.             {
  124.                 g.drawOval(200,100,50,50);
  125.             }
  126.             else
  127.             {
  128.                 g.drawLine(200,100, 250,150);
  129.                 g.drawLine(250,100, 200,150);
  130.             }
  131.         }
  132.         else if(x >=250 && x<=300 && y<=150) {
  133.             joueur++;
  134.             if(joueur % 2 == 0)
  135.             {
  136.                 g.drawOval(250,100,50,50);
  137.             }
  138.             else
  139.             {
  140.                 g.drawLine(250,100, 300,150);
  141.                 g.drawLine(300,100, 250,150);
  142.             }
  143.         }
  144.         //2eme ligne fin
  145.         else if(x >=50 && x<=100 && y<=200) {
  146.             joueur++;
  147.             if(joueur % 2 == 0)
  148.             {
  149.                 g.drawOval(50,150,50,50);
  150.             }
  151.             else
  152.             {
  153.                 // * /
  154.                 g.drawLine(50,200, 100,150);
  155.                 g.drawLine(100,200, 50,150);
  156.             }
  157.         }
  158.         else if(x >=100 && x<=150 && y<=200) {
  159.             joueur++;
  160.             if(joueur % 2 == 0)
  161.             {
  162.                 g.drawOval(100,150,50,50);
  163.             }
  164.             else
  165.             {
  166.                 g.drawLine(100,200, 150,150);
  167.                 g.drawLine(150,200, 100,150);
  168.             }
  169.         }
  170.         else if(x >=150 && x<=200 && y<=200) {
  171.             joueur++;
  172.             if(joueur % 2 == 0)
  173.             {
  174.                 g.drawOval(150,150,50,50);
  175.             }
  176.             else
  177.             {
  178.                 g.drawLine(150,200, 200,150);
  179.                 g.drawLine(200,200, 150,150);
  180.             }
  181.         }
  182.         else if(x >=200 && x<=250 && y<=200) {
  183.             joueur++;
  184.             if(joueur % 2 == 0)
  185.             {
  186.                 g.drawOval(200,150,50,50);
  187.             }
  188.             else
  189.             {
  190.                 g.drawLine(200,200, 250,150);
  191.                 g.drawLine(250,200, 200,150);
  192.             }
  193.         }
  194.         else if(x >=250 && x<=300 && y<=200) {
  195.             joueur++;
  196.             if(joueur % 2 == 0)
  197.             {
  198.                 g.drawOval(250,150,50,50);
  199.             }
  200.             else
  201.             {
  202.                 g.drawLine(250,200, 300,150);
  203.                 g.drawLine(300,200, 250,150);
  204.             }
  205.         }
  206.         else if(x >=50 && x<=100 && y<=250) {
  207.             joueur++;
  208.             if(joueur % 2 == 0)
  209.             {
  210.                 g.drawOval(50,200,50,50);
  211.  
  212.             }
  213.             else
  214.             {
  215.                 g.drawLine(50,250, 100,200);
  216.                 g.drawLine(100,250, 50,200);
  217.             }
  218.         }
  219.         else if(x >=100 && x<=150 && y<=250) {
  220.             joueur++;
  221.             if(joueur % 2 == 0)
  222.             {
  223.                 g.drawOval(100,200,50,50);
  224.             }
  225.             else
  226.             {
  227.                 g.drawLine(100,250, 150,200);
  228.                 g.drawLine(150,250, 100,200);
  229.             }
  230.  
  231.         }
  232.         else if(x >=150 && x<=200 && y<=250) {
  233.             joueur++;
  234.             if(joueur % 2 == 0)
  235.             {
  236.                 g.drawOval(150,200,50,50);
  237.             }
  238.             else
  239.             {
  240.                 g.drawLine(150,250, 200,200);
  241.                 g.drawLine(200,250, 150,200);
  242.             }
  243.         }
  244.         else if(x >=200 && x<=250 && y<=250) {
  245.             joueur++;
  246.             if(joueur % 2 == 0)
  247.             {
  248.                 g.drawOval(200,200,50,50);
  249.             }
  250.             else
  251.             {
  252.                 g.drawLine(200,250, 250,200);
  253.                 g.drawLine(250,250, 200,200);
  254.             }
  255.         }
  256.         else if(x >=250 && x<=300 && y<=250) {
  257.             joueur++;
  258.             if(joueur % 2 == 0)
  259.             {
  260.                 g.drawOval(250,200,50,50);
  261.             }
  262.             else
  263.             {
  264.                 g.drawLine(250,250, 300,200);
  265.                 g.drawLine(300,250, 250,200);
  266.             }
  267.         }
  268.         else if(x >=50 && x<=100 && y<=300) {
  269.             joueur++;
  270.             if(joueur % 2 == 0)
  271.             {
  272.                 g.drawOval(50,250,50,50);
  273.             }
  274.             else
  275.             {
  276.                 g.drawLine(50,300, 100,250);
  277.                 g.drawLine(100,300, 50,250);
  278.             }
  279.         }
  280.         else if(x >=100 && x<=150 && y<=300) {
  281.             joueur++;
  282.             if(joueur % 2 == 0)
  283.             {
  284.                 g.drawOval(100,250,50,50);
  285.             }
  286.             else
  287.             {
  288.                 g.drawLine(100,300, 150,250);
  289.                 g.drawLine(150,300, 100,250);
  290.             }
  291.         }
  292.         else if(x >=150 && x<=200 && y<=300) {
  293.             joueur++;
  294.             if(joueur % 2 == 0)
  295.             {
  296.                 g.drawOval(150,250,50,50);
  297.             }
  298.             else
  299.             {
  300.                 g.drawLine(150,300, 200,250);
  301.                 g.drawLine(200,300, 150,250);
  302.             }
  303.         }
  304.         else if(x >=200 && x<=250 && y<=300) {
  305.             joueur++;
  306.             if(joueur % 2 == 0)
  307.             {
  308.                 g.drawOval(200,250,50,50);
  309.             }
  310.             else
  311.             {
  312.                 g.drawLine(200,300, 250,250);
  313.                 g.drawLine(250,300, 200,250);
  314.             }
  315.         }
  316.         else if(x >=250 && x<=300 && y<=300) {
  317.             joueur++;
  318.             if(joueur % 2 == 0)
  319.             {
  320.                 g.drawOval(250,250,50,50);
  321.             }
  322.             else
  323.             {
  324.                 g.drawLine(250,300, 300,250);
  325.                 g.drawLine(300,300, 250,250);
  326.             }
  327.         }else {
  328.             System.out.println("none of them");
  329.          }
  330.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement