Advertisement
Adumb_Copper

Checkerboard

Oct 3rd, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2. import org.kussmaul.simplegraphics.*;
  3. import org.kussmaul.simplegraphics.item.SimpleItem;
  4.  
  5. public class Question1
  6. {
  7.    
  8.     static int test[][] = {{0,0}, {1,0}, {2,0}, {0,1}, {0,2}, {0,3}};
  9.    
  10.     Scanner scan = new Scanner(System.in);
  11.     static SimpleGraphics sg = new SimpleGraphics();
  12.     static SimpleItem square;
  13.     static SimpleItem circle;
  14.    
  15.     public static void main(String[] args)
  16.     {
  17.         drawBoard();
  18.         drawCheckers(test);
  19.     }
  20.    
  21.     public static void drawBoard()
  22.     {
  23.         for (int i = 0; i < 800; i += 100)
  24.         {
  25.             for (int j = 0; j < 800; j += 100)
  26.             {
  27.                 square = sg.drawRect(i, j, 100);
  28.             }
  29.         }
  30.     }
  31.    
  32.     public static void drawCheckers(int[][] positions)
  33.     {
  34.         for (int[] yx : positions)
  35.         {
  36.             if (yx[0] % 2 != yx[1] % 2)
  37.             {
  38.                 circle = sg.drawOval((yx[0] * 100) + 20, (yx[1] * 100) + 20, 60);
  39.             }
  40.             else
  41.             {
  42.                 circle = sg.fillOval((yx[0] * 100) + 20, (yx[1] * 100) + 20, 60);
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement